Class 11 Computer Science Chapter 5 Functions In Python Quiz 2 (60 MCQs)

Quiz Instructions

Select an option to see the correct answer instantly.

1. What will be printed by the following code? "'pythondef add(a, b):return a + bprint(add(3, 5)) "'
2. Which of the following is NOT a benefit of using functions?
3. What is the purpose of the math module in Python?
4. What will be the output of the following code? def display():print('program') display()
5. Assertion. A parameter having a default value in the function header is known as a default parameter.Reason. The default values for parameters are considered only if no value is provided for that parameter in the function call statement.
6. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(obj2, 12)
7. What is the output of the following code? def add(x, y):return x + y; print(add(2, 3))
8. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(spacing=20)
9. What is the primary purpose of a for loop in Python?
10. What is the correct way to define a function that multiplies two numbers?
11. How do you call a function in Python?
12. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(obj3, collapse=0)
13. What is the output of the following code:'print((lambda x, y:x + y)(10, 5))'?
14. What will be the output of the following code? "'pythondef greet(name="Guest"):return "Hello, '' + nameprint(greet()) "'
15. A ..... is a block of code that will execute only when it is called.
16. What will points.count(9) return if points = [1, 4, 2, 9, 7, 8, 9, 3, 1]?
17. What is the output of the following code? def my ..... func():print('hello, Good Morning'); my ..... func()
18. Which of the following best describes a parameter in a function?
19. What is the output of a function that returns a list?
20. What are the advantages of using lambda functions in Python?
21. Which of the following items are present in the function header?
22. Which of the following is an example of a non-parameterized function?
23. The program may run out of memory in a
24. What will this code print?def hello():print("Hi")hello()
25. How do you create a multi-line string in Python?
26. A variable defined outside all functions is known as
27. What does the ..... name ..... variable indicate when a module is imported?
28. What is the default return value of a function that does not return any value explicitly?
29. What is the scope of a variable defined inside a function in Python?
30. Name the condition at which the recursive method will stop calling itself.
31. Choose the correct form of function.
32. What will be the output of the following code? "'pythondef add(a, b):return a + bresult = add(3, 4)print(result) "'
33. Which of the following is true about the lifetime of a variable in Python?
34. What does the keyword return do in a Python function or subroutine?
35. A named blocks of code that are designed to do one specific job is called as
36. If a function is defined but never called, what will happen?
37. While defining a function which of the following symbol is used?
38. What will be the output of the following code snippet?print(type(5 / 2))print(type(5 // 2))
39. Which of the following is a valid way to call a function named 'calculate' in Python?
40. What will be printed by the following code? "'pythondef foo(x):if x < 0:return "Negative" else:return "Non-negative"print(foo(-5)) "'
41. This statement causes a function to end and sends a value back to the part of the program that called the function.
42. What is the output of the following code:'print((lambda x, y:x-y)(5, 3))'?
43. What is the output of the function call sums() if sums() returns 30?
44. Ananya is trying to understand the features of Python functions. She is not understanding the feature that distributes the work in small parts. Select the appropriate term out of the following.
45. Why is the number 20 not part of the list generated by list(range(2, 20, 2))?
46. What will the following code output? def even ..... odd():no = int(input('Enter a number:')); if no % 2 == 0:print('Even') else:print('Odd')
47. What is the purpose of the 'return' keyword in a function?
48. Which method would you use to insert an element at a specific position in a list?
49. How can you return multiple values from a function in Python?
50. Which of the following function headers is correct?*
51. Which of the following is a valid function definition in Python?
52. When possible, you should avoid using ..... variables in a program.
53. What does the function round(x, n) do in Python?
54. Out of the following, find those identifiers, which cannot be used for naming functions in a Python program:While, 3rd Row, def, My ..... Sp
55. Select output given by the following code:a = {i * i for i in range(6)}print(a)
56. What does the keyword 'def' signify in Python?
57. In Python function can return only one value.
58. What does the following function return? "'pythondef multiply(x, y=2):return x * yprint(multiply(4)) "'
59. Which of the following is a correct way to use the map function to double each element in a list?
60. If we write def add(a, b):return a + b, what will add(2, 3) give?