This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 3 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 3 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Read the following statement and choose the correct statement(s)1.In python, you don't have to mention the specific data types while defining function2.Python keywords can be used as function names A) I is correct and II is wrong. B) I is wrong and II is correct. C) Both are correct. D) Both are wrong. Show Answer Correct Answer: A) I is correct and II is wrong. 2. Assertion. A variable declared inside a function cannot be used outside it.Reason. A variable created inside a function has a function scope. 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. 3. What is the correct syntax to define a function with variable-length arguments in Python? A) 'def myFunction(*args):'. B) 'def myFunction(args*):'. C) 'def myFunction(*args):'. D) 'def myFunction(args*):'. Show Answer Correct Answer: A) 'def myFunction(*args):'. 4. What is the scope of a variable defined inside a function? A) Local. B) Dynamic. C) Static. D) Global. Show Answer Correct Answer: A) Local. 5. Which of these is TRUE about a function that uses return? A) It cannot take parameters. B) It gives a value back to the program. C) It always works without inputs. D) It only prints the answer on the screen. Show Answer Correct Answer: B) It gives a value back to the program. 6. What will the following code output? def multiply(x, y):return x * y; print(multiply(4, 5)) A) 9. B) 45. C) 20. D) Error. Show Answer Correct Answer: C) 20. 7. Which of the following is NOT a valid function parameter in Python? A) 'def func(x y):'. B) 'def func(x=5):'. C) 'def func(*args):'. D) 'def func(x, y):'. Show Answer Correct Answer: A) 'def func(x y):'. 8. Which of the following is a valid way to define a function with variable-length arguments? A) 'def myFunction(*args):'. B) 'def myFunction(args*):'. C) 'def myFunction(args):'. D) 'def myFunction(*args):'. Show Answer Correct Answer: A) 'def myFunction(*args):'. 9. ..... is a blank space in the beginning of a statement within a block. A) Indention. B) Space. C) Body. D) None of the above. Show Answer Correct Answer: A) Indention. 10. Consider the line of code:Label('Go Team', 200, 100)What is the Label? A) Argument. B) Parameter. C) Function name. D) None of the above. Show Answer Correct Answer: C) Function name. 11. Which of the following is correct regarding an Argument? A) A variable which we use in the function definition. B) A value we pass when we call the function. C) The order in which statements are executed. D) A keyword used to return a result from a function. Show Answer Correct Answer: B) A value we pass when we call the function. 12. You ..... a function to execute it. A) Define. B) Import. C) Call. D) Export. Show Answer Correct Answer: C) Call. 13. What is the purpose of the main function? A) To define the mainline logic of the program. B) To call other functions when needed. C) To execute the program. D) Both A and B. Show Answer Correct Answer: D) Both A and B. 14. Which type of function allows returning multiple values in Python? A) Multi-value function. B) Dictionary function. C) Single-value function. D) Tuple function. Show Answer Correct Answer: D) Tuple function. 15. What is the output of the following code? def sub(x, y):return x-y; print(sub(10, 5)) A) Error. B) 10. C) 15. D) 5. Show Answer Correct Answer: D) 5. 16. What is the correct way to call a function named 'calculate' with arguments '5' and '10'? A) 'calculate{5, 10}'. B) 'calculate(5, 10)'. C) 'calculate[5, 10]'. D) 'calculate<5, 10>'. Show Answer Correct Answer: B) 'calculate(5, 10)'. 17. In which arguments the correct positional order is passed to a function? A) Required. B) Variable-length. C) Keyword. D) Default. Show Answer Correct Answer: A) Required. 18. Pick the correct one to execute the given statement successfully.if:print(x, "is a leap year") A) X%4=0. B) X%2==0. C) X%4==0. D) X/4=0. Show Answer Correct Answer: C) X%4==0. 19. Which of the following is the use of id() function in python? A) Id returns the identity of the object. B) Every object doesn't have a unique id. C) All of the mentioned. D) None of the mentioned. Show Answer Correct Answer: A) Id returns the identity of the object. 20. Which of the following is not true about functions? A) They divide a large program into smaller modules. B) Provide a systematic way of problem solving. C) Make the program difficult to manage and understand. D) Helps in creating user defined libraries. Show Answer Correct Answer: C) Make the program difficult to manage and understand. 21. Recursion is similar to which of the following? A) If-else. B) Switch-case. C) Loops. D) None of the above. Show Answer Correct Answer: C) Loops. 22. Which of the following is a correct way to define a function with two parameters? A) 'def myFunc(x:y):'. B) 'def myFunc(x; y):'. C) 'def myFunc(x, y):'. D) 'def myFunc(x y):'. Show Answer Correct Answer: C) 'def myFunc(x, y):'. 23. What is the output of 'len('Hello')'? A) 6. B) Hello. C) 5. D) 4. Show Answer Correct Answer: C) 5. 24. Which of these in not a built in function? A) Type(). B) Len(). C) Power(). D) Int(). Show Answer Correct Answer: C) Power(). 25. Which of the following pertains to a piece of code that can take inputs to perform a specific task? A) Functions. B) Loops. C) Arguments. D) Parameters. Show Answer Correct Answer: A) Functions. 26. Which of the following is the correct way to define a function in Python that takes no parameters? A) 'function myFunction():'. B) 'def myFunction():'. C) 'define myFunction():'. D) 'func myFunction():'. Show Answer Correct Answer: B) 'def myFunction():'. 27. Which of the following is a correct way to use a lambda function to add 10 to each element in a list? A) 'map(lambda x:x + 10, list of numbers)'. B) 'map(lambda x:x * 10, list of numbers)'. C) 'map(lambda x:x-10, list of numbers)'. D) 'map(lambda x:x / 10, list of numbers)'. Show Answer Correct Answer: A) 'map(lambda x:x + 10, list of numbers)'. 28. What is the output of the following code:'print((lambda x, y, z:x * y * z)(2, 3, 4))'? A) 12. B) 8. C) 24. D) 9. Show Answer Correct Answer: C) 24. 29. What is the output of the following code? "'pythondef change():x = 5 return xx = 10print(change())print(x) "' A) '5' followed by '10'. B) '5' followed by '5'. C) '10' followed by '5'. D) '10' followed by '10'. Show Answer Correct Answer: A) '5' followed by '10'. 30. What is the difference between '==' and 'is' when comparing strings? A) The '==' operator compares object identity, while 'is' compares values. B) The '==' operator compares values, while 'is' compares object identity. C) Both '==' and 'is' compare values but return different results. D) The '==' operator checks for type, while 'is' checks for value. Show Answer Correct Answer: B) The '==' operator compares values, while 'is' compares object identity. 31. What is the correct syntax to define a function in Python? A) 'def myFunction():'. B) 'define myFunction():'. C) 'function myFunction():'. D) 'func myFunction():'. Show Answer Correct Answer: A) 'def myFunction():'. 32. Which of the following is NOT a valid lambda function? A) 'lambda x:x * 2'. B) 'lambda x, y:x + y'. C) 'lambda x, y, z:x + y + z'. D) 'lambda:x + 2'. Show Answer Correct Answer: D) 'lambda:x + 2'. 33. What will be the output of the following code? "'pythondef concat(str1, str2):return str1 + str2result = concat("Hello, ", "World!")print(result) "' A) 'Hello, '. B) 'Hello World!'. C) 'Hello, World!'. D) 'World!'. Show Answer Correct Answer: C) 'Hello, World!'. 34. What is the correct way to import a module in Python? A) Import module name. B) Require module name. C) Include module name. D) Load module name. Show Answer Correct Answer: A) Import module name. 35. Explain the use of lambda functions in Python. A) Lambda functions provide a concise way to create small, unnamed functions for quick use without formally defining them using 'def'. B) Lambda functions are primarily used for creating global variables in Python. C) Lambda functions can only take one argument in Python. D) Lambda functions are only used for defining classes in Python. Show Answer Correct Answer: A) Lambda functions provide a concise way to create small, unnamed functions for quick use without formally defining them using 'def'. 36. What will be printed by the following code? "'pythondef foo():a = 7 return aa = 3print(foo())print(a) "' A) '3' followed by '7'. B) '7' followed by '7'. C) '3' followed by '3'. D) '7' followed by '3'. Show Answer Correct Answer: D) '7' followed by '3'. 37. What will be the output of the following code? "'pythondef increment(x):x += 1 return xvalue = 5result = increment(value)print(result) "' A) '6'. B) '5'. C) '7'. D) 'None'. Show Answer Correct Answer: A) '6'. 38. Assertion (A):There are various built in functions/methods to manipulate the dictionaries. Reason (R):Built in functions does not work on dictionaries. 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: C) A is true but R is false. 39. The ..... of a variable is the area of the program where it may be referred. A) Local. B) Scope. C) Global. D) External. Show Answer Correct Answer: B) Scope. 40. What term is used to describe data passed into a function? A) Variable. B) Parameter. C) Constant. D) Loop. Show Answer Correct Answer: B) Parameter. 41. Values can be passed to the function using variables. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 42. What is the general format for defining a function? A) Define function name(). B) Function function name() {}. C) Function name() = def. D) Def function name():. Show Answer Correct Answer: D) Def function name():. 43. What will be the output of the following code? "'pythondef double(x):return x * 2result = double(7)print(result) "' A) '14'. B) '7'. C) '0'. D) 'None'. Show Answer Correct Answer: A) '14'. 44. What are the reasons for using functions in programs, A) To build code that will be reused. B) To simplify code. C) Help us to organize longer programs. D) All of the above. Show Answer Correct Answer: D) All of the above. 45. A variable created or defined within a function body is A) Local. B) Instance. C) Built in. D) Global. Show Answer Correct Answer: A) Local. 46. In Python, how do you call a subroutine named calculate ..... average from the main program? A) A. calculate average(). B) B. call calculate average(). C) C. run calculate average(). D) None of the above. Show Answer Correct Answer: A) A. calculate average(). 47. What is the output of the following code? def main():i=4; a=add(4); print(a); main() A) 8. B) Error. C) 4. D) 16. Show Answer Correct Answer: D) 16. 48. What is the correct way to define a function with a default parameter value? A) 'def myFunction(x=10):'. B) 'def myFunction(x:10):'. C) 'def myFunction(x=10)'. D) 'def myFunction(x, 10):'. Show Answer Correct Answer: A) 'def myFunction(x=10):'. 49. What is the output of the function call print(add ..... five(square(4)))? A) 25. B) 21. C) 16. D) 20. Show Answer Correct Answer: B) 21. 50. What does the range() function return in Python 3? A) A string of numbers. B) A tuple of numbers. C) An iterable object. D) A list of numbers. Show Answer Correct Answer: C) An iterable object. 51. Which of the following is not a part of the python function? A) Function keyword. B) Return statement. C) Parameter list. D) Function header. Show Answer Correct Answer: A) Function keyword. 52. Which of the following is true about the scope of variables in Python? A) Variables defined inside a function have global scope. B) Variables defined inside a function are accessible outside the function. C) Variables defined outside a function are accessible inside the function. D) Variables defined outside a function have local scope. Show Answer Correct Answer: C) Variables defined outside a function are accessible inside the function. 53. What does a negative step size in Python indicate? A) Dividing. B) Multiplying. C) Incrementing. D) Decrementing. Show Answer Correct Answer: D) Decrementing. 54. Functions make code re-usable A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 55. What is the difference between an argument and a parameter? A) Arguments are used in function definition, parameters in function call. B) None of the above. C) Parameters are used in function definition, arguments in function call. D) They are the same. Show Answer Correct Answer: C) Parameters are used in function definition, arguments in function call. 56. What are keyword arguments in function calls? A) Arguments that cannot be named explicitly. B) Arguments that are always required. C) Arguments that are passed in a specific order. D) Keyword arguments are arguments passed to a function by explicitly naming the parameters. Show Answer Correct Answer: D) Keyword arguments are arguments passed to a function by explicitly naming the parameters. 57. What will be the output of the following code? def func(s):return len(s); print(func('Hello')) A) None. B) Error. C) Hello. D) 5. Show Answer Correct Answer: D) 5. 58. What will be the output of the following code? "'pythondef power(base, exponent):return base ** exponentresult = power(2, 3)print(result) "' A) '8'. B) '6'. C) '9'. D) 'None'. Show Answer Correct Answer: A) '8'. 59. How can you pass a list as an argument to a function in Python? A) 'myFunction<1, 2, 3>'. B) 'myFunction{1, 2, 3}'. C) 'myFunction(1, 2, 3)'. D) 'myFunction([1, 2, 3])'. Show Answer Correct Answer: D) 'myFunction([1, 2, 3])'. 60. What is the default return value of a function that does not have a 'return' statement? A) '0'. B) 'None'. C) 'False'. D) 'True'. Show Answer Correct Answer: B) 'None'. ← 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 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