This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 2 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books 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)) "' A) '3 + 5'. B) '35'. C) 'Error'. D) '8'. Show Answer Correct Answer: D) '8'. 2. Which of the following is NOT a benefit of using functions? A) Increased complexity. B) Reusability. C) Readability. D) Modularity. Show Answer Correct Answer: A) Increased complexity. 3. What is the purpose of the math module in Python? A) To perform mathematical calculations. B) To store functions. C) To create random numbers. D) To manage input and output. Show Answer Correct Answer: A) To perform mathematical calculations. 4. What will be the output of the following code? def display():print('program') display() A) Program. B) None. C) Error. D) Display. Show Answer Correct Answer: A) Program. 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. A) Both A and R are true and R is the correct explanation of A. B) Both A and R are true but R is NOT the correct explanation of A. C) A is true but R is false. D) A is false but R is true. Show Answer Correct Answer: B) Both A and R are true but R is NOT the correct explanation of A. 6. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(obj2, 12) A) Valid. B) Invalid. C) All the above. D) None of the above. Show Answer Correct Answer: A) Valid. 7. What is the output of the following code? def add(x, y):return x + y; print(add(2, 3)) A) 23. B) None. C) Error. D) 5. Show Answer Correct Answer: D) 5. 8. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(spacing=20) A) Valid. B) Invalid. C) All the above. D) None of the above. Show Answer Correct Answer: B) Invalid. 9. What is the primary purpose of a for loop in Python? A) To define a function. B) To iterate over items in a sequence. C) To create a variable. D) To handle exceptions. Show Answer Correct Answer: B) To iterate over items in a sequence. 10. What is the correct way to define a function that multiplies two numbers? A) Def mult x, y:. B) Def mult(x, y). C) Def mult(x, y):. D) Def mult(x, y):. Show Answer Correct Answer: C) Def mult(x, y):. 11. How do you call a function in Python? A) Function(arguments). B) Function name[]. C) Call function(arguments). D) Function name(arguments). Show Answer Correct Answer: D) Function name(arguments). 12. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(obj3, collapse=0) A) Valid. B) Invalid. C) All the above. D) None of the above. Show Answer Correct Answer: A) Valid. 13. What is the output of the following code:'print((lambda x, y:x + y)(10, 5))'? A) 15. B) 105. C) 5. D) 50. Show Answer Correct Answer: A) 15. 14. What will be the output of the following code? "'pythondef greet(name="Guest"):return "Hello, '' + nameprint(greet()) "' A) 'Hello, Guest'. B) 'Hello, '. C) 'Hello, None'. D) 'Error'. Show Answer Correct Answer: A) 'Hello, Guest'. 15. A ..... is a block of code that will execute only when it is called. A) Function. B) Sub Program. C) Block. D) All of the above. Show Answer Correct Answer: A) Function. 16. What will points.count(9) return if points = [1, 4, 2, 9, 7, 8, 9, 3, 1]? A) 9. B) 2. C) 0. D) 1. Show Answer Correct Answer: B) 2. 17. What is the output of the following code? def my ..... func():print('hello, Good Morning'); my ..... func() A) Hello, Good Morning. B) My func. C) None. D) Error. Show Answer Correct Answer: A) Hello, Good Morning. 18. Which of the following best describes a parameter in a function? A) A variable defined inside a function and used only there. B) A variable listed in the function definition and used to pass values. C) A variable that is always global. D) A variable that cannot be changed. Show Answer Correct Answer: B) A variable listed in the function definition and used to pass values. 19. What is the output of a function that returns a list? A) A list. B) A string. C) A dictionary. D) An integer. Show Answer Correct Answer: A) A list. 20. What are the advantages of using lambda functions in Python? A) Lambda functions in Python have several advantages, including being concise, anonymous, and useful for one-time functions and as arguments in higher-order functions. B) Lambda functions in Python are slower than regular functions. C) Lambda functions in Python can only be used for simple tasks. D) Lambda functions in Python are difficult to debug. Show Answer Correct Answer: A) Lambda functions in Python have several advantages, including being concise, anonymous, and useful for one-time functions and as arguments in higher-order functions. 21. Which of the following items are present in the function header? A) Function name only. B) Both function name and parameter list. C) Parameter list only. D) Return value. Show Answer Correct Answer: B) Both function name and parameter list. 22. Which of the following is an example of a non-parameterized function? A) Def add(x, y):. B) Def greet():. C) Def sum(a, b):. D) Def multiply(x, y):. Show Answer Correct Answer: B) Def greet():. 23. The program may run out of memory in a A) Non-recursive function call. B) Recursive function call. C) Condition when too many variables are declared. D) None of the above. Show Answer Correct Answer: B) Recursive function call. 24. What will this code print?def hello():print("Hi")hello() A) Hello. B) Hi. C) Nothing. D) Error. Show Answer Correct Answer: B) Hi. 25. How do you create a multi-line string in Python? A) Use single quotes to create a multi-line string. B) Use triple quotes (" ' or """) to create a multi-line string. C) Use parentheses to create a multi-line string. D) Concatenate multiple strings with a backslash. Show Answer Correct Answer: B) Use triple quotes (" ' or """) to create a multi-line string. 26. A variable defined outside all functions is known as A) Static. B) Global. C) Local. D) None of the above. Show Answer Correct Answer: B) Global. 27. What does the ..... name ..... variable indicate when a module is imported? A) The name of the module. B) The main program. C) The function being executed. D) None of the above. Show Answer Correct Answer: A) The name of the module. 28. What is the default return value of a function that does not return any value explicitly? A) Int. B) Float. C) Double. D) None. Show Answer Correct Answer: D) None. 29. What is the scope of a variable defined inside a function in Python? A) Limited to the class. B) Limited to the function. C) Accessible from any function. D) Global scope. Show Answer Correct Answer: B) Limited to the function. 30. Name the condition at which the recursive method will stop calling itself. A) Base case. B) Worst Case. C) Best Case. D) None of the above. Show Answer Correct Answer: A) Base case. 31. Choose the correct form of function. A) Func stat():. B) Def stat( ):. C) Def stat( ). D) Def static:. Show Answer Correct Answer: B) Def stat( ):. 32. What will be the output of the following code? "'pythondef add(a, b):return a + bresult = add(3, 4)print(result) "' A) '7'. B) '34'. C) 'None'. D) 'Error'. Show Answer Correct Answer: A) '7'. 33. Which of the following is true about the lifetime of a variable in Python? A) A variable's lifetime is until the function ends. B) A variable's lifetime is until the variable is deleted. C) A variable's lifetime is until the module is reloaded. D) A variable's lifetime is until the program ends. Show Answer Correct Answer: A) A variable's lifetime is until the function ends. 34. What does the keyword return do in a Python function or subroutine? A) A. Terminates the program. B) B. Sends a value back to the caller. C) C. Defines a loop. D) None of the above. Show Answer Correct Answer: B) B. Sends a value back to the caller. 35. A named blocks of code that are designed to do one specific job is called as A) Loop. B) Block. C) Branching. D) Function. Show Answer Correct Answer: D) Function. 36. If a function is defined but never called, what will happen? A) Python will still run it automatically. B) It will not run at all. C) It will give an error. D) It will print "Nothing". Show Answer Correct Answer: B) It will not run at all. 37. While defining a function which of the following symbol is used? A) $ dollar. B) :colon. C) ; semicolon. D) .dot. Show Answer Correct Answer: B) :colon. 38. What will be the output of the following code snippet?print(type(5 / 2))print(type(5 // 2)) A) Float and int. B) Int and float. C) Float and float. D) Int and int. Show Answer Correct Answer: A) Float and int. 39. Which of the following is a valid way to call a function named 'calculate' in Python? A) 'call calculate()'. B) 'execute calculate()'. C) 'calculate()'. D) 'run calculate()'. Show Answer Correct Answer: C) 'calculate()'. 40. What will be printed by the following code? "'pythondef foo(x):if x < 0:return "Negative" else:return "Non-negative"print(foo(-5)) "' A) '-5'. B) 'Error'. C) 'Negative'. D) 'Non-negative'. Show Answer Correct Answer: C) 'Negative'. 41. This statement causes a function to end and sends a value back to the part of the program that called the function. A) Terminate. B) Return. C) End. D) Break. Show Answer Correct Answer: B) Return. 42. What is the output of the following code:'print((lambda x, y:x-y)(5, 3))'? A) 1. B) 15. C) 2. D) 8. Show Answer Correct Answer: C) 2. 43. What is the output of the function call sums() if sums() returns 30? A) 30. B) None. C) Error. D) Sums. Show Answer Correct Answer: A) 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. A) Modularity. B) Abstraction. C) Reusability. D) Simplicity. Show Answer Correct Answer: A) Modularity. 45. Why is the number 20 not part of the list generated by list(range(2, 20, 2))? A) Because the upper limit is excluded while generating the iterable. B) Because the step size is incorrect. C) Because the upper limit is included while generating the iterable. D) Because 20 is included in the list. Show Answer Correct Answer: A) Because the upper limit is excluded while generating the iterable. 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') A) Error. B) Even or Odd based on input. C) Even. D) None. Show Answer Correct Answer: B) Even or Odd based on input. 47. What is the purpose of the 'return' keyword in a function? A) To print a value. B) To define a function. C) To end the function. D) To return a value to the caller. Show Answer Correct Answer: D) To return a value to the caller. 48. Which method would you use to insert an element at a specific position in a list? A) Remove(). B) Append(). C) Insert(). D) Extend(). Show Answer Correct Answer: C) Insert(). 49. How can you return multiple values from a function in Python? A) Using a list. B) Using a tuple. C) Using a dictionary. D) All of the above. Show Answer Correct Answer: D) All of the above. 50. Which of the following function headers is correct?* A) Def fun(a = 2, b = 3, c). B) Def fun(a = 2, b, c = 3). C) Def fun(a, b, c = 3, d). D) Def fun(a, b = 2, c = 3). Show Answer Correct Answer: D) Def fun(a, b = 2, c = 3). 51. Which of the following is a valid function definition in Python? A) 'def myFunction:'. B) 'def myFunction():'. C) 'def myFunction[]:'. D) 'def myFunction{}'. Show Answer Correct Answer: B) 'def myFunction():'. 52. When possible, you should avoid using ..... variables in a program. A) Global. B) Local. C) Constant. D) Parameter. Show Answer Correct Answer: A) Global. 53. What does the function round(x, n) do in Python? A) Returns the largest integer less than or equal to x. B) Returns a float value by rounding off x to n digits. C) Returns the smallest integer greater than or equal to x. D) Returns the absolute value of x. Show Answer Correct Answer: B) Returns a float value by rounding off x to n digits. 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 A) 3rd Row. B) Def. C) While. D) My Sp. Show Answer Correct Answer: B) Def. 55. Select output given by the following code:a = {i * i for i in range(6)}print(a) A) {0:0, 1:1, 2:4, 3:9, 4:16, 5:25, 6:36}. B) Dictionary comprehension doesn't exist. C) {0, 1, 4, 9, 16, 25}. D) {0:1, 1:2, 4:3, 9:4, 16:5, 25}. Show Answer Correct Answer: C) {0, 1, 4, 9, 16, 25}. 56. What does the keyword 'def' signify in Python? A) Define a function. B) Define a class. C) Define a loop. D) Define a variable. Show Answer Correct Answer: A) Define a function. 57. In Python function can return only one value. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 58. What does the following function return? "'pythondef multiply(x, y=2):return x * yprint(multiply(4)) "' A) '8'. B) '6'. C) '4'. D) '2'. Show Answer Correct Answer: A) '8'. 59. Which of the following is a correct way to use the map function to double each element in a list? A) 'map(lambda x:x * 2, list of numbers)'. B) 'map(lambda x:x-2, list of numbers)'. C) 'map(lambda x:x / 2, list of numbers)'. D) 'map(lambda x:x + 2, list of numbers)'. Show Answer Correct Answer: A) 'map(lambda x:x * 2, list of numbers)'. 60. If we write def add(a, b):return a + b, what will add(2, 3) give? A) 5. B) 23. C) Error. D) A+b. Show Answer Correct Answer: A) 5. ← PreviousNext →Related QuizzesScience QuizzesClass 11 QuizzesClass 11 Computer Science Chapter 5 Functions In Python Quiz 1Class 11 Computer Science Chapter 5 Functions In Python Quiz 3Class 11 Computer Science Chapter 5 Functions In Python Quiz 4Class 11 Computer Science Chapter 5 Functions In Python Quiz 5Class 11 Computer Science Chapter 5 Functions In Python Quiz 6Class 11 Computer Science Chapter 5 Functions In Python Quiz 7Class 11 Computer Science Chapter 1 Computer Fundamentals QuizClass 11 Computer Science Chapter 2 Introduction To Python Quiz 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books