This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 13 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 13 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What is the lifetime of a variable defined inside a function? A) Until the program ends. B) Until the function ends. C) Until the variable is deleted. D) Until the module is reloaded. Show Answer Correct Answer: B) Until the function ends. 2. Which of the following is the correct way to handle errors in a Python function? A) 'try except'. B) 'catch throw'. C) 'error handle'. D) 'if else'. Show Answer Correct Answer: A) 'try except'. 3. Parameters in a function are like: A) The name of the function. B) The input we give to the function. C) The result we get. D) The computer screen. Show Answer Correct Answer: B) The input we give to the function. 4. ..... is the built-in function to know the type of a variable or function. A) Id(). B) Type(). C) Data type(). D) None of the above. Show Answer Correct Answer: B) Type(). 5. What is the syntax to define a function in Python? A) Def function name():. B) Define function name():. C) Function function name():. D) Create function name():. Show Answer Correct Answer: A) Def function name():. 6. These are predefined functions that are always available for use. For using them we don't need to import any module. A) Built function. B) Predefined function. C) User defined. D) None of the above. Show Answer Correct Answer: A) Built function. 7. Which of the following is a valid lambda function that returns the square of a number? A) 'lambda x:x * x'. B) 'lambda x:x + x'. C) 'lambda x:x-x'. D) 'lambda x:x / x'. Show Answer Correct Answer: A) 'lambda x:x * x'. 8. What function is used to find the length of a string? A) Len(). B) Length(). C) Count(). D) Size(). Show Answer Correct Answer: A) Len(). 9. What does the randint function do? A) Generates a random float. B) Generates a random integer within a range. C) Generates a random string. D) Generates a random list. Show Answer Correct Answer: B) Generates a random integer within a range. 10. Which of the following is a keyword used to define a function in Python? A) 'function'. B) 'def'. C) 'define'. D) 'func'. Show Answer Correct Answer: B) 'def'. 11. How do you use a lambda function with the filter() function in Python? A) Pass the lambda function as the last argument to the filter() function. B) Pass the lambda function as the third argument to the filter() function. C) Pass the lambda function as the second argument to the filter() function. D) Pass the lambda function as the first argument to the filter() function. Show Answer Correct Answer: D) Pass the lambda function as the first argument to the filter() function. 12. Which of the following is NOT a reason to use functions? A) To reduce code duplication. B) To make a program more modular. C) To demonstrate intellectual superiority. D) To make a program more self-documenting. Show Answer Correct Answer: C) To demonstrate intellectual superiority. 13. Which of these statements about a function is correct? A) A function runs only when it is called. B) A function runs automatically every time we open Python. C) A function is just a variable. D) A function is a number. Show Answer Correct Answer: A) A function runs only when it is called. 14. What is the default behavior of the sort() method? A) Sorts in ascending order. B) Does not sort the list. C) Sorts based on the length of elements. D) Sorts in descending order. Show Answer Correct Answer: A) Sorts in ascending order. 15. Def Fun ..... love(a, 20):print(a+20)is A) Correct. B) Incorrect. C) Has Syntax error. D) Will print 20 added to value of a. Show Answer Correct Answer: C) Has Syntax error. 16. How can you use a lambda function to sort a list of tuples by the second element? A) 'sorted(list of tuples, key=lambda x:x[0])'. B) 'sorted(list of tuples, key=lambda x:x[1])'. C) 'sorted(list of tuples, key=lambda x:x[2])'. D) 'sorted(list of tuples, key=lambda x:x[-1])'. Show Answer Correct Answer: B) 'sorted(list of tuples, key=lambda x:x[1])'. 17. If the return statement is not used in the function then which type of value will be returned by the function? A) Int. B) Str. C) Float. D) None. Show Answer Correct Answer: D) None. 18. Which operator is used to check if a value exists in a sequence? A) In. B) Exists. C) Contains. D) Has. Show Answer Correct Answer: A) In. 19. Which of the following cannot be converted in a recursion function? A) Factorial program. B) Random function generation. C) Binary search. D) Greatest common divisor(GCD). Show Answer Correct Answer: B) Random function generation. 20. The default value for a parameter is defined in function ..... ? A) Definition. B) Return statement. C) Header. D) None of the above. Show Answer Correct Answer: C) Header. 21. Which statement is correct to import all modules from the package A) From package import all. B) From package import *. C) From package include all. D) From package include *. Show Answer Correct Answer: B) From package import *. 22. How do you print 'Hello' five times using a for loop? A) For i in range(5):print('Hello'). B) Print('Hello' * 5). C) For i in range(0, 6, 2):print('Hello'). D) Print('Hello' + 'Hello' + 'Hello' + 'Hello' + 'Hello'). Show Answer Correct Answer: A) For i in range(5):print('Hello'). 23. Assertion (A):Built in function are predefined in the language that are used directly. Reason (R):print() and input() are built in functions. 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: B) Both A and R are true and R is not correct explanation for A. 24. What does the append() method do in Python lists? A) Returns the last element of the list. B) Adds an element to the end of the list. C) Inserts an element at a specific position. D) Removes an element from the list. Show Answer Correct Answer: B) Adds an element to the end of the list. 25. Parameters are the (a) used in the function definition. A) A. variables. B) Values. C) Constant. D) Method. Show Answer Correct Answer: A) A. variables. ← 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