This quiz works best with JavaScript enabled. Home > Class 11 > 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 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Why are functions useful in programming? A) They make the program longer. B) They help us avoid writing the same code again. C) They make the computer slower. D) They are only used in games. Show Answer Correct Answer: B) 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, 6]. C) [2, 4]. 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 static variable. B) A global 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) 0. B) 1. C) -1. D) 2. Show Answer Correct Answer: B) 1. 9. What is the default start value in Python if it is not provided? A) 0. B) 1. C) 2. D) 3. Show Answer Correct Answer: A) 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: B) '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) .pym. B) .pymodule. C) .module. D) .py. Show Answer Correct Answer: D) .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) Type( ). B) Len( ). C) Def findSum():. D) Eval( ). 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) Lambda. D) Return. 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) 9. B) 6. C) Error. D) 3. Show Answer Correct Answer: B) 6. 22. A variable that's declared inside a function is ..... to that function A) Private. B) Specific. C) Global. D) Local. Show Answer Correct Answer: D) Local. 23. What will be the output of this program?def hello():print( "I am a beginner" )hello()hello() A) I am a beginner. B) I am a beginner I am a beginner. C) Hello. D) HelloHello. E) I am a beginnerI am a beginner. Show Answer Correct Answer: E) 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) 'Hello Alice'. C) 'Hello, '. D) 'Alice'. Show Answer Correct Answer: A) 'Hello, Alice'. Next →Related 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 5 Functions In Python Quiz 8Class 11 Computer Science Chapter 5 Functions In Python Quiz 9Class 11 Computer Science Chapter 5 Functions In Python Quiz 10Class 11 Computer Science Chapter 5 Functions In Python Quiz 11 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books