Answers Already Passed
What is a function in Python?
✔✔A reusable block of code designed to perform a specific task.
How do you define a function in Python?
✔✔Use the `def` keyword followed by the function name and parentheses.
What is the purpose of a return statement in a function?
✔✔To send a value back to the caller of the function.
How do you call a function in Python?
✔✔Use the function name followed by parentheses.
What is a parameter in a function?
✔✔A variable listed inside the parentheses in a function definition.
1
,What is an argument in Python?
✔✔A value passed to a function when it is called.
What happens if a function does not have a return statement?
✔✔The function returns `None` by default.
How can you pass multiple arguments to a function?
✔✔Separate them with commas in the function call.
What is a default parameter in a function?
✔✔A parameter that has a predefined value if no argument is provided.
How do you specify a default parameter in Python?
✔✔Assign a value to the parameter in the function definition.
What is the purpose of the `*args` syntax in Python?
✔✔It allows a function to accept a variable number of positional arguments.
2
, What does the `**kwargs` syntax do in a function?
✔✔It allows a function to accept a variable number of keyword arguments.
How can you make a function return multiple values?
✔✔Return the values as a tuple or other collection.
What is the difference between positional and keyword arguments?
✔✔Positional arguments are passed in order, while keyword arguments are passed with a name-
value pair.
How do you document a function in Python?
✔✔Use a docstring, which is a string enclosed in triple quotes inside the function definition.
What is the purpose of a lambda function in Python?
✔✔To create small, anonymous functions in a single line.
How do you create a lambda function?
✔✔Use the `lambda` keyword followed by parameters and an expression.
3