11. What does the *args syntax in a function definition mean?
12. What is the purpose of using recursion in a function?
13. What is the output of the following code:
def greet(name):
print(f"Hello, {name}!")
greet("Alice")
def greet(name):
print(f"Hello, {name}!")
greet("Alice")
14. What is the purpose of a function in Python?
15. What is a variable defined outside a function referred to as?
16. Where are the arguments received from the command line stored?
17. What is the purpose of using the ** symbol in function argument unpacking?
18. What will be the output of the following Python code?
def sum(*args):
'''Function returns the sum
of all values'''
r = 0
for i in args:
r += i
return r
print sum.__doc__
print sum(1, 2, 3)
print sum(1, 2, 3, 4, 5)
def sum(*args):
'''Function returns the sum
of all values'''
r = 0
for i in args:
r += i
return r
print sum.__doc__
print sum(1, 2, 3)
print sum(1, 2, 3, 4, 5)
19. What will be the output of the following Python code?
min = (lambda x, y: x if x < y else y)
min(101*99, 102*98)
min = (lambda x, y: x if x < y else y)
min(101*99, 102*98)
20. The nested list undergoes shallow copy even when the list as a whole undergoes deep copy.
Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.