This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 4 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 4 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What does the function header contain? A) The function name. B) The function name and parameter list. C) The parameter list. D) The return value. Show Answer Correct Answer: B) The function name and parameter list. 2. What is the purpose of a user-defined function? A) To create variables. B) To perform a specific task defined by the user. C) To handle errors. D) To execute built-in functions. Show Answer Correct Answer: B) To perform a specific task defined by the user. 3. How do you call a function named 'calculate ..... sum' in Python? A) 'call calculate sum'. B) 'calculate sum()'. C) 'def calculate sum()'. D) 'execute calculate sum()'. Show Answer Correct Answer: B) 'calculate sum()'. 4. What is the output of the following code? "'pythondef sum ..... and ..... diff(a, b):return a + b, a-bresult = sum ..... and ..... diff(7, 3)print(result) "' A) 'Error'. B) '10 4'. C) '7, 3'. D) '(10, 4)'. Show Answer Correct Answer: D) '(10, 4)'. 5. What is the output of the following code:'print((lambda x:x / 2)(8))'? A) 16. B) 0. C) 2. D) 4. Show Answer Correct Answer: D) 4. 6. What does the return statement do in a function? A) Calls another function. B) Prints the output. C) Returns a value to the caller. D) Ends the program. Show Answer Correct Answer: C) Returns a value to the caller. 7. By default, if you return multiple values separated by commas, then it is returned as A) List. B) Tuples. C) String. D) None of the above. Show Answer Correct Answer: B) Tuples. 8. Which of the following condition is true? A) Recursion is always better than iteration. B) Recursion uses more memory as compared to iteration. C) Recursion uses less memory as compared to iteration. D) Iteration is always better and simpler than recursion. Show Answer Correct Answer: B) Recursion uses more memory as compared to iteration. 9. How do you call a lambda function in Python? A) By using the name of the lambda function followed by parentheses. B) By using the 'execute' function on the lambda function. C) By using the 'call' method on the lambda function. D) By using the 'lambda' keyword followed by parentheses. Show Answer Correct Answer: A) By using the name of the lambda function followed by parentheses. 10. Aman wants to write a function in Python but doesn't know how to start it. Select the keyword used to start a function out of the following. A) Def. B) Start. C) Fun. D) Function. Show Answer Correct Answer: A) Def. 11. What does the random function return? A) A random integer. B) A random float in the range of 0.0 and 1.0. C) A random float with a specified range. D) None of the above. Show Answer Correct Answer: B) A random float in the range of 0.0 and 1.0. 12. Identify the function that returns the number of items in a list. A) Count(). B) Len(). C) Items(). D) Count(). Show Answer Correct Answer: B) Len(). 13. Pick one from the following statements to correctly complete the function body to get the output 5 in the given code snippet:def f(number):#missing function bodyprint(f(5)) A) Return number. B) Print(number). C) Return "number". D) Print("number"). Show Answer Correct Answer: A) Return number. 14. A ..... is a variable that is created inside a function. A) Static variable. B) Local variable. C) Global variable. D) Constant variable. Show Answer Correct Answer: B) Local variable. 15. What does the index() method return? A) The last element of the list. B) The first occurrence of a specified value's position. C) The total number of elements in the list. D) A copy of the list. Show Answer Correct Answer: B) The first occurrence of a specified value's position. 16. If you want to find the maximum value in a list, which method would you use? A) Sum(). B) Max(). C) Min(). D) Len(). Show Answer Correct Answer: B) Max(). 17. Which of the following is the correct way to catch any exception in Python? A) 'except Exception:'. B) 'catch Exception:'. C) 'except:'. D) 'handle Exception:'. Show Answer Correct Answer: C) 'except:'. 18. What will be printed by the following code? "'pythondef test():y = 5 print(y)test()print(y) "' A) '5' followed by '5'. B) '5' followed by 'Error'. C) 'Error' only. D) 'None'. Show Answer Correct Answer: B) '5' followed by 'Error'. 19. How can you convert a string to uppercase in Python? A) String variable.toUpperCase(). B) String variable.upper(). C) String variable.capitalize(). D) String variable.uppercase(). Show Answer Correct Answer: B) String variable.upper(). 20. Predefined functions that are already available in Python are known as A) Built-in functions. B) User defined functions. C) Modules. D) Scripts. Show Answer Correct Answer: A) Built-in functions. 21. Which of the following is used to return a result from a function? A) Catch. B) Break. C) Continue. D) Return. Show Answer Correct Answer: D) Return. 22. Which of the following keyword is used to begin the function block? A) Define. B) For. C) Finally. D) Def. Show Answer Correct Answer: D) Def. 23. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)? A) [3, 5, 20, 5, 25, 1, 3]. B) [3, 4, 5, 20, 5, 25, 1, 3]. C) [1, 3, 3, 4, 5, 5, 20, 25]. D) [1, 3, 4, 5, 20, 5, 25]. Show Answer Correct Answer: A) [3, 5, 20, 5, 25, 1, 3]. 24. What is the purpose of using subroutines in programming? A) A. To confuse the programmer. B) B. To make the code longer. C) C. To organize code and make it more modular and reusable. D) None of the above. Show Answer Correct Answer: C) C. To organize code and make it more modular and reusable. 25. What is the output of the following code? def print ..... is ..... positive(n):if n > 0:print('Positive'); else:print('Negative'); print ..... is ..... positive(-5) A) Positive. B) Negative. C) None. D) Error. Show Answer Correct Answer: B) Negative. 26. A Function that does not have any return value is known as ..... A) Library function. B) Void function. C) Fruitful function. D) None of the above. Show Answer Correct Answer: B) Void function. 27. What is a parameter in the context of functions? A) A function that calls another function. B) A value returned by a function. C) A variable in a function definition. D) A built-in function. Show Answer Correct Answer: C) A variable in a function definition. 28. What is the output of the following code:'print((lambda x:x**2)(5))'? A) 10. B) 25. C) 0. D) 5. Show Answer Correct Answer: B) 25. 29. What is the output of the function shown below (random module has already been imported)?random.choice('sun') A) Either s, u or n. B) Sun. C) U. D) Error. Show Answer Correct Answer: A) Either s, u or n. 30. What does the function sqrt(x) return? A) The square of x. B) The square root of x. C) The cube of x. D) None of the above. Show Answer Correct Answer: B) The square root of x. 31. Function may or may not return a value A) True. B) False. C) None. D) None. Show Answer Correct Answer: A) True. 32. The ..... of a variable is the area of a program where it may be referenced A) Local. B) External. C) Scope. D) Global. Show Answer Correct Answer: C) Scope. 33. Which of the following is TRUE about global variables? A) They must be integers. B) They cannot be changed. C) They are only accessible inside the function where they are defined. D) They are accessible from any function unless shadowed by a local variable of the same name. Show Answer Correct Answer: D) They are accessible from any function unless shadowed by a local variable of the same name. 34. What is the format for writing a value-returning function? A) Return expression. B) Return value. C) Def function name():. D) Function name(). Show Answer Correct Answer: A) Return expression. 35. What does the following function return? "'pythondef test():passprint(test()) "' A) 'None'. B) 'pass'. C) 'test'. D) 'Error'. Show Answer Correct Answer: A) 'None'. 36. What happens if the function is not called? A) It will throw an error. B) The function will respond as usual. C) The function will get deleted. D) The function will not work. Show Answer Correct Answer: D) The function will not work. 37. The code block of function always comes after a ..... A) :. B) #. C) '. D) ;. Show Answer Correct Answer: A) :. 38. Assertion (A):Built in function are predefined in the language that are used directlyReason (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 the 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 the correct explanation for A. 39. The first line of a function definition is known as the ..... A) Body. B) Initialization. C) Introduction. D) Header. Show Answer Correct Answer: D) Header. 40. Recall what will a function return if there is no return statement. A) 0. B) None. C) Error. D) Empty String. Show Answer Correct Answer: B) None. 41. Def fun1(a, b):return a+b, a=b, a*b, a/ba=fun1(10, 2)Here a will be created as A) Dictionary. B) Tuple. C) String. D) List. Show Answer Correct Answer: B) Tuple. 42. How can you check the type of a variable in Python? A) Check the variable's memory address. B) Use the 'type()' function. C) Use the 'instanceof' operator. D) Use the 'var type()' function. Show Answer Correct Answer: B) Use the 'type()' function. 43. Which Python function returns the length of a string or a list? A) Range(). B) Min(). C) Max(). D) Len(). Show Answer Correct Answer: D) Len(). 44. Assertion. A parameter having a default in function header becomes optional in function call.Reason. A function call may or may not have values for default arguments. 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. 45. Predict the output, if the value passed for the given function is 2.def game(x):return 4**x A) 16. B) 4 4. C) X x. D) 8. Show Answer Correct Answer: A) 16. 46. What type of argument is passed during function definition? A) Formal Parameter. B) Positional Argument. C) Default Argument. D) Actual Argument. Show Answer Correct Answer: A) Formal Parameter. 47. What is the purpose of the 'break' statement in Python? A) To skip the rest of the code in the loop and continue with the next iteration. B) To terminate the loop and transfer control to the next statement. C) To execute a set of statements repeatedly based on a condition. D) To define a new variable. Show Answer Correct Answer: B) To terminate the loop and transfer control to the next statement. 48. Read the following statements and then select the answer:Statement A:Default arguments can be used to add new parameters to the existing functionsStatement B:Default arguments can be used to combine similar functions into one A) Statement A is correct. B) Statement B is correct. C) Both are correct. D) Both are incorrect. Show Answer Correct Answer: C) Both are correct. 49. What is the output of the following Python code?print(round(51.6)) A) 51.6. B) Round(51.6). C) 52. D) 51. Show Answer Correct Answer: C) 52. 50. What will be the output of the following code? "'pythondef max ..... value(a, b):if a > b:return a else:return bresult = max ..... value(5, 10)print(result) "' A) '10'. B) '5'. C) '0'. D) 'None'. Show Answer Correct Answer: A) '10'. 51. What is the output of the following code? def main():print('This is python'); main() A) None. B) Error. C) Main. D) This is python. Show Answer Correct Answer: D) This is python. 52. What is the order of resolving scope of a name in a python program? A) B E G L. B) G E B L. C) L E G B. D) L B E G. Show Answer Correct Answer: C) L E G B. 53. Which of the following is a valid use of a lambda function? A) Defining a class. B) Creating a complex multi-line function. C) Writing a quick, throwaway function. D) Handling file input/output. Show Answer Correct Answer: C) Writing a quick, throwaway function. 54. Which of the following is a characteristic of a parameterized function? A) Does not take inputs. B) Takes one or more inputs. C) Always returns a value. D) None of the above. Show Answer Correct Answer: B) Takes one or more inputs. 55. A function can be with or without returning any values. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 56. What is the correct way to define a function that returns nothing? A) 'def myFunction():pass'. B) 'def myFunction():return'. C) 'def myFunction():return None'. D) All of the above. Show Answer Correct Answer: D) All of the above. 57. Which method reverses the order of elements in a list? A) Sort(). B) Flip(). C) Order(). D) Reverse(). Show Answer Correct Answer: D) Reverse(). 58. What happens if the base condition isn't defined in recursive programs? A) Program runs n number of times where n is the argument given to the function. B) Program gets into an infinite loop. C) An exception is thrown. D) Program runs once. Show Answer Correct Answer: B) Program gets into an infinite loop. 59. What is the output of the following code:'print((lambda x:x-2)(10))'? A) 12. B) 8. C) 0. D) 2. Show Answer Correct Answer: B) 8. 60. What is the term for a function that calls itself in Python? A) Self function. B) Recursive function. C) Iterative function. D) Loop function. Show Answer Correct Answer: B) Recursive function. ← 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 2Class 11 Computer Science Chapter 5 Functions In Python Quiz 3Class 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