This keyword is used to define a function in Python.
What is def?
In the function definition def greet(name):, name is known as this.
What is a parameter?
This keyword is used to send a value back from a function to the caller.
What is return?
This wonderfully concise keyword is used to define anonymous functions in Python.
What is lambda?
You are designing a billing system. Write a function calculate_total(price, tax) that returns the total cost after adding tax.
What is:
def calculate_total(price, tax): return price + (price * tax)
This value is automatically returned from a function if no return statement is used.
What is None?
In the function call greet("Alice"), "Alice" is this type of value.
What is an argument?
What is the return value of a function that has no return statement?
What is None?
This is the output of the code:
What is `6`?
A Python developer is designing a quiz app. Why is it beneficial to separate question display, user input, and answer checking into separate functions?
What is to improve modularity, readability, and reuse of code?
This function definition contains a syntax error: def hello: print("Hi"). Identify the mistake.
What is missing parentheses after hello?
This type of argument is used when a default value is assigned in the function definition. Example: def greet(name="Guest")
What is a default argument?
Consider this function:
What is the output of print(add(2, 3))?
Fill in the blank to create a lambda that adds two numbers:
`lambda x, y: ____`
What is `x + y`?
You're tasked with optimizing a hospital’s appointment system. The team has written a single 100-line function that handles input, validation, scheduling, and messaging. What is a better design approach and why?
What is to break the large function into smaller, single-responsibility functions to follow clean code and modular programming principles?
This is how you define a function named square that returns the square of its input n.
What is def square(n): return n * n?
Identify the output of this code:
What is `5`?
What will be the output of the following code?
What is `(1, 2, 3)` (a tuple)?
Analyze and explain the output:
What is `[2, 4, 6, 8]`?
A company is reviewing two function implementations for sorting product reviews: one with recursion and one with built-in sort(). As a software reviewer, how would you evaluate which to keep in production?
What is to evaluate based on efficiency, readability, maintainability, and appropriateness for the data size and context?