Python Programming - Functions

Exercise : Functions - General Questions
  • Functions - General Questions
36.
What does the term "lambda function" refer to?
A function with a lengthy definition
A function defined using the def keyword
A function with a single line of code
A function that calls itself
Answer: Option
Explanation:
A lambda function in Python is a concise way to define a function with a single line of code.

37.
What is the purpose of the sum() function?
Computes the sum of elements in an iterable
Checks if a variable is of a certain type
Converts a list to uppercase
Sorts elements of a list in ascending order
Answer: Option
Explanation:
The sum() function is used to compute the sum of elements in an iterable, such as a list.

38.
What does the term "function signature" refer to?
The name of the function
The parameters and their types in a function
The return type of a function
A function with a single line of code
Answer: Option
Explanation:
The function signature in Python includes the name of the function, along with the parameters and their types.

39.
What is the purpose of the isinstance() function?
Checks if a variable is of a certain type
Determines if an object is callable as a function
Reverses the order of elements in a list
Converts a string to uppercase
Answer: Option
Explanation:
The isinstance() function is used to check if a variable is of a certain type.

40.
What will be the output of the following code snippet?
def greet(name="User"):
    return f"Hello, {name}!"

message = greet()
print(message)
Hello, User!
Hello, None!
Error
Hello, World!
Answer: Option
Explanation:
The default value for the parameter name is "User," so if no argument is provided, it uses the default.