This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 1 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 1 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Why are functions useful in programming? A) They are only used in games. B) They make the computer slower. C) They make the program longer. D) They help us avoid writing the same code again. Show Answer Correct Answer: D) They help us avoid writing the same code again. 2. Functions provide ..... to problem solving A) Divide and conquer approach. B) Modular approach. C) Both 1 and 2. D) None of the above. Show Answer Correct Answer: C) Both 1 and 2. 3. What is the output of the following code? def update ..... list(L):for i in range(len(L)):if L[i] % 2 == 0:L[i] += 2; update ..... list([2, 4, 6]) A) [2, 4, 6, 8]. B) [2, 4]. C) [2, 4, 6]. D) [4, 6, 8]. Show Answer Correct Answer: D) [4, 6, 8]. 4. Assertion. A function is a subprogram.Reason. A function exists within a program and works within it when called. 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: A) Both A and R are true and R is the correct explanation of A. 5. What is a variable defined inside all the function referred to as? A) A global variable. B) A static variable. C) A local variable. D) An automatic variable. Show Answer Correct Answer: C) A local variable. 6. Assertion (A):It is not possible to delete/remove the elements from a list. Reason (R):The pop(), remove(), del() functions are used to remove/delete the elements from the list. A) Both A and R are true and R is the correct explanation for A. B) Both A and R are true and R is not correct explanation for A. C) A is true but R is false. D) A is false but R is true. Show Answer Correct Answer: D) A is false but R is true. 7. What is the purpose of the randrange function? A) Returns a randomly selected integer from a sequence. B) Returns a random float in the range of 0.0 and 1.0. C) Returns a random float but allows user to specify range. D) Initializes the formula that generates random numbers. Show Answer Correct Answer: A) Returns a randomly selected integer from a sequence. 8. What is the output of the following code:'print((lambda x:x + 1)(0))'? A) 1. B) 0. C) -1. D) 2. Show Answer Correct Answer: A) 1. 9. What is the default start value in Python if it is not provided? A) 2. B) 0. C) 1. D) 3. Show Answer Correct Answer: B) 0. 10. What will the following code output? def average(n):total = 0; for i in range(1, n + 1):total += i; return total / n; print(average(10)) A) 5.5. B) 10. C) Error. D) None. Show Answer Correct Answer: A) 5.5. 11. Which of the following keyword is used to exit a function block? A) Define. B) Return. C) Finally. D) Def. Show Answer Correct Answer: B) Return. 12. How can you use a lambda function to map a list of numbers to their squares? A) 'map(lambda x:x-x, list of numbers)'. B) 'map(lambda x:x / x, list of numbers)'. C) 'map(lambda x:x + x, list of numbers)'. D) 'map(lambda x:x * x, list of numbers)'. Show Answer Correct Answer: D) 'map(lambda x:x * x, list of numbers)'. 13. You can call a function only once after defining it. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 14. How can you pass a list to a function in Python? A) Define a function with a parameter, then call it with a list as an argument. B) Lists cannot be passed as arguments in Python. C) You can only pass strings to a function. D) Functions cannot accept any parameters in Python. Show Answer Correct Answer: A) Define a function with a parameter, then call it with a list as an argument. 15. A Python module is a file with the ..... file extension that contains valid Python code. A) .py. B) .pymodule. C) .module. D) .pym. Show Answer Correct Answer: A) .py. 16. What is the difference between mutable and immutable data types? A) Mutable data types are always faster than immutable data types. B) Both mutable and immutable data types can be modified at any time. C) Mutable data types can be modified; immutable data types cannot be modified after creation. D) Mutable data types cannot be modified; immutable data types can be modified after creation. Show Answer Correct Answer: C) Mutable data types can be modified; immutable data types cannot be modified after creation. 17. Which of the following is not a built-in function? A) Len( ). B) Eval( ). C) Def findSum():. D) Type( ). Show Answer Correct Answer: C) Def findSum():. 18. What does the following code print? def greet():print('Hello!') greet() A) Hello!. B) Greet(). C) Error. D) None. Show Answer Correct Answer: A) Hello!. 19. What is a subroutine in Python? A) A type of variable. B) A sequence of instructions that performs a specific task. C) A reserved keyword in Python. D) None of the above. Show Answer Correct Answer: B) A sequence of instructions that performs a specific task. 20. A Function which calls itself is called as A) Built-in. B) Recursion. C) Return. D) Lambda. Show Answer Correct Answer: B) Recursion. 21. What will be the output of the following code? def add(j):if(j>=4):j=j*j else:j=j*2 return j; print(add(3)) A) Error. B) 3. C) 9. D) 6. Show Answer Correct Answer: D) 6. 22. A variable that's declared inside a function is ..... to that function A) Global. B) Private. C) Local. D) Specific. Show Answer Correct Answer: C) Local. 23. What will be the output of this program?def hello():print( "I am a beginner" )hello()hello() A) I am a beginner I am a beginner. B) I am a beginner. C) I am a beginnerI am a beginner. D) HelloHello. E) Hello. Show Answer Correct Answer: C) I am a beginnerI am a beginner. 24. What is the default return value for a function that does not return a value explicitly? A) None. B) Int. C) Double. D) Null. Show Answer Correct Answer: A) None. 25. What will be the output of the following code? "'pythondef greet(name):return "Hello, '' + nameprint(greet("Alice")) "' A) 'Hello Alice'. B) 'Alice'. C) 'Hello, Alice'. D) 'Hello, '. Show Answer Correct Answer: C) 'Hello, Alice'. 26. What method would you use to replace a substring in a string? A) Use the 'replace' method. B) Use the 'concat' method. C) Use the 'substring' method. D) Use the 'split' method. Show Answer Correct Answer: A) Use the 'replace' method. 27. In ..... arguments we can skip the default argument, but all the arguments should match the parameters in the function definitions. A) Keyword. B) Required. C) Default. D) None of the above. Show Answer Correct Answer: A) Keyword. 28. Which statement about function parameters is TRUE? A) All parameters must have default values. B) Parameters can be given default values. C) Parameters cannot be named. D) Parameters must always be integers. Show Answer Correct Answer: B) Parameters can be given default values. 29. What will be the output of the following code? "'pythondef subtract(a, b):return a-bresult = subtract(10, 4)print(result) "' A) '6'. B) '14'. C) '-6'. D) 'None'. Show Answer Correct Answer: A) '6'. 30. Select which of the following is NOT TRUE for Python function: A) A function only executes when it is called and we can reuse it in a program. B) In a Python function a keyword argument can not be followed by a positional argument. C) A Python function can return multiple values. D) Python function doesn't return anything unless and until you add a return statement. Show Answer Correct Answer: D) Python function doesn't return anything unless and until you add a return statement. 31. What is the correct syntax to call a function named 'calculate ..... Area'? A) Calculate Area{}. B) Calculate Area(). C) Calculate Area;. D) Calculate Area[]. Show Answer Correct Answer: B) Calculate Area(). 32. Do you call or define a function first? A) Call. B) Define. C) All the above. D) None of the above. Show Answer Correct Answer: B) Define. 33. In Python, if no value is provided in the function call, the argument takes (a) value. A) A. default. B) Temporary. C) Provided. D) Expounded. Show Answer Correct Answer: A) A. default. 34. How can you check if a substring exists within a string? A) Check the length of the string. B) Use the 'find()' method in Python. C) Use the 'in' operator in Python or 'includes()' method in JavaScript. D) Use the 'indexOf()' method in JavaScript. Show Answer Correct Answer: C) Use the 'in' operator in Python or 'includes()' method in JavaScript. 35. What are positional arguments in function calls? A) Positional arguments are arguments passed to a function in the order of its parameters. B) Arguments that can be passed in any order. C) Arguments that are optional and not required. D) Arguments that are defined by their names. Show Answer Correct Answer: A) Positional arguments are arguments passed to a function in the order of its parameters. 36. Which of the following functions is a built-in function in python? A) Sqrt(). B) Factorial(). C) Array(). D) Print(). Show Answer Correct Answer: A) Sqrt(). 37. What is the output of the following code:'print((lambda x, y:x * y)(3, 4))'? A) 7. B) 1. C) 12. D) 34. Show Answer Correct Answer: C) 12. 38. Which function returns the largest of its arguments? A) Max(). B) Len(). C) Min(). D) Range(). Show Answer Correct Answer: A) Max(). 39. Which of the following symbols always comes after a function code block? A) #. B) ;. C) :. D) ]. Show Answer Correct Answer: C) :. 40. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(ob1) A) Valid. B) Invalid. C) All the above. D) None of the above. Show Answer Correct Answer: A) Valid. 41. Can a lambda function have multiple expressions in Python? A) Sometimes. B) Only if it is nested. C) No. D) Yes. Show Answer Correct Answer: D) Yes. 42. What does the map function in Python do? A) It filters elements from an iterable based on a condition. B) It applies a given function to each item of an iterable and returns a list of the results. C) It sorts the elements of an iterable in ascending order. D) It reduces an iterable to a single cumulative value. Show Answer Correct Answer: B) It applies a given function to each item of an iterable and returns a list of the results. 43. What is the output of the following code? "'pythondef divide(a, b):try:return a / b except ZeroDivisionError:return "Cannot divide by zero"print(divide(10, 0)) "' A) '0'. B) 'Cannot divide by zero'. C) 'ZeroDivisionError'. D) 'None'. Show Answer Correct Answer: B) 'Cannot divide by zero'. 44. Def info(object, spacing=10, collapse=1):# function headerconsider the following function call and find out whether it is validinfo(spacing=15, object=obj4) A) Valid. B) Invalid. C) All the above. D) None of the above. Show Answer Correct Answer: A) Valid. 45. What is the output of the following code? "'pythonx = 10def show():print(x)show() "' A) '10'. B) 'x'. C) 'Error'. D) 'None'. Show Answer Correct Answer: A) '10'. 46. What is a void function? A) A function that has no parameters. B) A function that performs an action but doesn't return a value. C) A function that cannot be called. D) A function that returns a value. Show Answer Correct Answer: B) A function that performs an action but doesn't return a value. 47. When you use multiple type argument in function then default argument take place A) At beginning. B) At end. C) Anywhere. D) None of the above. Show Answer Correct Answer: B) At end. 48. How to call this function?def sayHello( ):print ( "Hello World!" ) A) Sayhello( ):. B) SayHello( ). C) SayHello( ):. D) Sayhello( ). Show Answer Correct Answer: B) SayHello( ). 49. Which of the following is the correct syntax for a lambda function? A) 'def lambda(x):x + 2'. B) 'lambda(x) { return x + 2 }'. C) 'function lambda(x) { x + 2 }'. D) 'lambda x:x + 2'. Show Answer Correct Answer: D) 'lambda x:x + 2'. 50. Which of the following is a valid function name? A) Start game(). B) Start game. C) Start-game(). D) All of the above. Show Answer Correct Answer: A) Start game(). 51. The values being passed through a function-call statement are called ..... A) Arguments. B) Parameter. C) Values. D) None. Show Answer Correct Answer: A) Arguments. 52. What is returned by math.ceil(3.4)? A) 4. B) 3. C) 4.0. D) 3.0. Show Answer Correct Answer: A) 4. 53. Select the advantages of functions A) Modular programming. B) Code re-usability. C) Improving clarity of the code. D) All the above. Show Answer Correct Answer: D) All the above. 54. What will be the output of the following code? "'pythondef is ..... even(number):return number % 2 == 0result = is ..... even(4)print(result) "' A) 'True'. B) 'False'. C) '0'. D) 'None'. Show Answer Correct Answer: A) 'True'. 55. What type of variable is declared inside a function? A) Local Variable. B) Instance Variable. C) Global Variable. D) Static Variable. Show Answer Correct Answer: A) Local Variable. 56. What is the output of the programx=50def func(x):x=2func(x)print("x value", x) A) 50. B) 2. C) 48. D) 52. Show Answer Correct Answer: A) 50. 57. Which of the following statements is false about recursion A) Every recursive function must have a base value. B) Infinite recursion can occur if the base case isn't properly mentioned. C) A recursive function makes the code short and simple. D) A recursive method is invoked differently from a non-recursive method. Show Answer Correct Answer: D) A recursive method is invoked differently from a non-recursive method. 58. What does the 'strip()' method do to a string? A) The 'strip()' method replaces all spaces with underscores. B) The 'strip()' method converts all characters to lowercase. C) The 'strip()' method removes leading and trailing whitespace from a string. D) The 'strip()' method splits a string into a list of words. Show Answer Correct Answer: C) The 'strip()' method removes leading and trailing whitespace from a string. 59. What is the output of the following Python code?num = 3print( float(num) ) A) 3.0. B) 3. C) Flaot(num). D) TypeError. Show Answer Correct Answer: A) 3.0. 60. What is the output of the following code:'list(map(lambda x:x**2, [1, 2, 3, 4]))'? A) [1, 4, 9, 16]. B) [1, 8, 27, 64]. C) [2, 4, 6, 8]. D) [1, 2, 3, 4]. Show Answer Correct Answer: A) [1, 4, 9, 16]. Next →Related QuizzesScience QuizzesClass 11 QuizzesClass 11 Computer Science Chapter 5 Functions In Python Quiz 2Class 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