Quiz on Function in Python
Q.1. Which of the following are the two main parts of every function in Python?
Q.2. Which of the following is true about user-defined functions in Python?
Q.3. What will be the output of the following Python code?
def sayHello():
print('Hello World!',end=" ")
sayHello()
sayHello()
Q.4. Which of the following is not a user-defined function?
Q.5. What is the output of the following display_person() function call
def display_person(*args):
for i in args:
print(i, end=" ")
display_person(name="Emma", age="25")
Q.6. What will be the output of the following Python code?
def printMax(a, b):
if a > b:
print(a, 'is maximum')
elif a == b:
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(3, 4)
Q.7. What is the default value of a function?
Q.8. What will be output for the folllowing code?
x = 50
def func(x):
print('x is', x, end="/ ")
x = 2
print('Changed local x to', x, end="/ ")
func(x)
print('x is now', x, end="/ ")
Q.9. What will be output for the folllowing code?
def adder(x, y):
print(x + y)
adder("1","2")
Q.10. What will be the output of the following Python code?
def minimum(x, y):
if x < y:
return x
elif x == y:
return 'The numbers are equal'
else:
return y
print(minimum(2, 3))
Q.11. Consider the following function:
Which of the following lines of codes is the function’s signature?
def square(num):
num_squared = num ** 2
return num_squared
Q.12. What is the output of the following code snippet?
func = lambda x: return x
print(func(2))
Q.13. What is the output of the following code snippet?
def say(message, times = 1):
print(message * times,end=" ")
say('Hello')
say('World', 5)
Q.14. Python function always returns a value
Q.15. What is the output of the following function call
def outer_fun(a, b):
def inner_fun(c, d):
return c + d
return inner_fun(a, b)
return a
result = outer_fun(5, 10)
print(result)
Instructions:-
- This Quiz is based on Function in Python
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP