This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 16 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 16 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Can a function in Python return multiple values? A) No. B) Maybe. C) Yes. D) Only if using a specific library. Show Answer Correct Answer: C) Yes. 2. What is the output of fruits.clear() if fruits = ['apple', 'banana', 'cherry']? A) ['apple', 'banana', 'cherry']. B) []. C) ['banana', 'cherry']. D) None. Show Answer Correct Answer: B) []. 3. Def = A) DEFINED. B) Define. C) Difine. D) DEFINE. Show Answer Correct Answer: B) Define. 4. What is a local variable? A) A variable that can be accessed anywhere in the program. B) A variable that is assigned a value inside a function. C) A variable that is global. D) A variable that cannot be changed. Show Answer Correct Answer: B) A variable that is assigned a value inside a function. 5. What is the purpose of using functions in programming? A) To make code longer. B) To improve readability and reusability. C) To avoid errors. D) To create variables. Show Answer Correct Answer: B) To improve readability and reusability. 6. Which keyword is used to send a value back from a function in Python? A) 'send'. B) 'return'. C) 'yield'. D) 'output'. Show Answer Correct Answer: B) 'return'. 7. What is the purpose of modularization in programming? A) To keep code organized. B) To make programs easier to understand. C) To reuse code. D) All of the above. Show Answer Correct Answer: D) All of the above. 8. User can change the functionality of a built in functions. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 9. What is the output of the following code? "'pythoncount = 0def increment():global count count += 1increment()print(count) "' A) '1'. B) '0'. C) 'Error'. D) 'count'. Show Answer Correct Answer: A) '1'. 10. How do you use the dir() function in Python? A) Use dir(object) to get a list of attributes and methods of the object. B) Use dir(object, attribute) to get specific attributes of the object. C) Call dir() without any arguments to see all built-in functions. D) Use dir() to print the object directly. Show Answer Correct Answer: A) Use dir(object) to get a list of attributes and methods of the object. 11. Which keyword marks the beginning of the function block A) Func. B) Define. C) Def. D) Function. Show Answer Correct Answer: C) Def. 12. What is the scope of variables declared at the top level of a module or directly in the interpreter? A) Immutable scope. B) Mutable scope. C) Global scope. D) Local scope. Show Answer Correct Answer: C) Global scope. 13. Can a function call itself in Python? If yes, what is it called? A) Repetition. B) Looping. C) Iteration. D) Recursion. Show Answer Correct Answer: D) Recursion. 14. Which of the following statements is true about functions in Python? A) Functions cannot return multiple values. B) Functions can be defined inside other functions. C) Functions cannot have default parameter values. D) Functions must always return a value. Show Answer Correct Answer: B) Functions can be defined inside other functions. 15. Fill in the line of code for calculating the factorial of a number.def fact(num):if num == 0:return 1 else:return ..... A) Num*fact(num-1). B) (num-1)*(num-2). C) Num*(num-1). D) Fact(num)*fact(num-1). Show Answer Correct Answer: A) Num*fact(num-1). 16. When large programs are broken down into smaller units known as ..... A) Sub program. B) Functions. C) Class. D) None of the above. Show Answer Correct Answer: B) Functions. 17. How do you pass a lambda function as an argument to another function in Python? A) By using the 'lambda' keyword as a parameter in the other function. B) By passing the lambda function as a string to the other function. C) By defining the lambda function inside the other function. D) By providing the lambda function as an argument when calling the other function. Show Answer Correct Answer: D) By providing the lambda function as an argument when calling the other function. 18. Def fun1(x, y):x = x + y y = x-y x = x-y print('a =', x) print('b =', y) a = 5 b = 3 fun1(a, b) A) A = 3b = 5. B) None. C) Error. D) A = 5b = 3. Show Answer Correct Answer: A) A = 3b = 5. 19. Which type of loop in Python is used when a set of statements needs to be executed repeatedly based on a condition? A) For loop. B) While loop. C) Do-while loop. D) Nested loop. Show Answer Correct Answer: B) While loop. 20. What is the syntax for a function with required arguments? A) Def add(a, b):return a + b. B) Def greet(name='Guest'):return 'Hello, ' + name. C) Def student details(name, age):return f'Name:\{name\}, Age:\{age\}'. D) Def total marks(*marks):return sum(marks). Show Answer Correct Answer: A) Def add(a, b):return a + b. 21. How do you access the first character of a string? A) Use string[0] to access the first character of a string. B) Retrieve the first character using string.slice(1, 2). C) Access the first character with string.charAt(1). D) Use string.first() to get the first character. Show Answer Correct Answer: A) Use string[0] to access the first character of a string. 22. Python passes arguments to function by A) Reference. B) Value. C) Both. D) None of the above. Show Answer Correct Answer: C) Both. 23. What function can be used to split a string into a list? A) Split(). B) Cut(). C) Break(). D) Divide(). Show Answer Correct Answer: A) Split(). 24. What is the purpose of an IPO chart? A) To describe the input, processing, and output of a function. B) To document functions. C) To simplify complex calculations. D) Both A and B. Show Answer Correct Answer: D) Both A and B. 25. When defining a function, the definition must occur before it is called. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. ← PreviousNext →Related QuizzesClass 11 Computer Science Chapter 5 Functions In Python Quiz 1Class 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 10 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books