This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 5 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 5 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What does the 'find()' method return if the substring is not found? A) Undefined. B) Null. C) 0. D) -1. Show Answer Correct Answer: D) -1. 2. Which of the following problems can be solved using recursion? A) Finding Nth number of the Fibonacci sequence. B) Finding the factorial of a number. C) Finding the length of a string. D) All of the above. Show Answer Correct Answer: D) All of the above. 3. What will be the output of the following code? "'pythondef remainder(a, b):return a % bresult = remainder(10, 3)print(result) "' A) '1'. B) '3'. C) '0'. D) 'None'. Show Answer Correct Answer: A) '1'. 4. What is the purpose of using lambda functions in Python? A) The purpose of using lambda functions in Python is to improve code readability. B) The purpose of using lambda functions in Python is to create anonymous functions. C) The purpose of using lambda functions in Python is to increase code performance. D) The purpose of using lambda functions in Python is to reduce code complexity. Show Answer Correct Answer: B) The purpose of using lambda functions in Python is to create anonymous functions. 5. How does a function differ from a subroutine? A) A. Functions and subroutines are the same. B) B. Functions are only used for math operations, while subroutines handle general tasks. C) C. Functions can return a value, while subroutines do not. D) None of the above. Show Answer Correct Answer: C) C. Functions can return a value, while subroutines do not. 6. How can you convert a string to lowercase? A) Use the .uppercase() method in Python. B) Use the .toUpperCase() method in Java. C) Use the .lower() method in Python or the .toLowerCase() method in JavaScript. D) Convert the string using string.replace() method. Show Answer Correct Answer: C) Use the .lower() method in Python or the .toLowerCase() method in JavaScript. 7. Def aver(a, b, c=10):return (a+b+c)/3requires ..... arguments compulsorily A) 0. B) 1. C) 2. D) 3. Show Answer Correct Answer: C) 2. 8. Richa is working with a program where she gave some values to the function. She doesn't know the term to relate these values. Select the correct option. A) Function value. B) Arguments or parameters. C) Return values. D) Function call. Show Answer Correct Answer: B) Arguments or parameters. 9. What does the max() function in Python do? A) It returns the smallest of its arguments. B) It returns the largest of its arguments. C) It returns the length of a string. D) It generates a sequence of numbers. Show Answer Correct Answer: B) It returns the largest of its arguments. 10. What will be the output of the following code? "'pythondef divide(a, b):return a / bresult = divide(8, 2)print(result) "' A) '4.0'. B) '4'. C) '0'. D) 'None'. Show Answer Correct Answer: A) '4.0'. 11. What is the syntax for a function with variable-length arguments? A) Def local example():x = 10. B) Def student info(**details):return details. C) Def total marks(*marks):return sum(marks). D) Def multiply(a, b):return a * b. Show Answer Correct Answer: C) Def total marks(*marks):return sum(marks). 12. Function randint() is available under which module of python? A) Random. B) Math. C) Statistics. D) None of the above. Show Answer Correct Answer: A) Random. 13. Which of the following statements is true about calling functions in Python? A) A function must be called with parentheses, even if it has no parameters. B) A function can be called without parentheses if it has no parameters. C) A function call must always include arguments. D) A function cannot be called from within another function. Show Answer Correct Answer: A) A function must be called with parentheses, even if it has no parameters. 14. Which of the following is a correct way to document a function in Python? A) '// This is a function'. B) '"""This is a function"""'. C) '# This is a function'. D) '/* This is a function */'. Show Answer Correct Answer: B) '"""This is a function"""'. 15. In which part of memory does the system stores the parameter and local variables of function call A) Heap. B) Stack. C) Both a and b. D) None of the above. Show Answer Correct Answer: B) Stack. 16. A function definition has ..... number of parts A) 3. B) 5. C) 6. D) 4. Show Answer Correct Answer: B) 5. 17. Function header in Python contains ..... A) Function name. B) List of parameters. C) Return type. D) All the above. E) Only A & B. Show Answer Correct Answer: E) Only A & B. 18. Assertion (A):A function is a block of organized and reusable code that is used to perform a single, related action. Reason (R):Function provides better modularity by your application and a high degree of code reusability. 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: A) Both A and R are true and R is the correct explanation for A. 19. Which of the given argument types can be skipped from a function call? A) Default arguments. B) Named arguments. C) Keyword arguments. D) Positional arguments. Show Answer Correct Answer: A) Default arguments. 20. Which of the following keywords marks the begining of the function block? A) Function. B) Func. C) Def. D) Define. Show Answer Correct Answer: C) Def. 21. What is string interpolation? A) A method for encrypting strings. B) A technique for formatting numbers. C) String interpolation is the process of inserting variable values into a string. D) A way to concatenate strings without variables. Show Answer Correct Answer: C) String interpolation is the process of inserting variable values into a string. 22. What type of arguments in a function call require the number of formal parameters to match the number of actual parameters? A) Positional arguments. B) Named arguments. C) Default arguments. D) Keyword arguments. Show Answer Correct Answer: A) Positional arguments. 23. Every function returns a value; if a function does not explicitly return a value, then it will return ..... A) Return. B) None. C) Value. D) All. Show Answer Correct Answer: B) None. 24. In the range(start, stop, step) function, what does the 'stop' parameter indicate? A) The step size for the sequence. B) The starting value of the number in the iterable. C) The ending value included in the iterable. D) The ending value excluded from the iterable. Show Answer Correct Answer: D) The ending value excluded from the iterable. 25. A(n) ..... is a special variable that receives a piece of data when a function is called. A) Argument. B) Parameter. C) Header. D) Module. Show Answer Correct Answer: B) Parameter. 26. Calling a function and defining a function mean the same thing. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 27. What is the syntax of a lambda function in Python? A) Lambda arguments:expression. B) Expression:lambda arguments. C) Expression:arguments lambda. D) Arguments:lambda expression. Show Answer Correct Answer: A) Lambda arguments:expression. 28. What is the purpose of the 'join()' method in strings? A) To find the length of a string. B) To replace all occurrences of a substring in a string. C) To split a string into a list of characters. D) The purpose of the 'join()' method is to combine elements of an iterable into a string with a specified separator. Show Answer Correct Answer: D) The purpose of the 'join()' method is to combine elements of an iterable into a string with a specified separator. 29. How can you modify a global variable inside a function? A) By using the 'static' keyword. B) By using the 'local' keyword. C) By using the 'global' keyword. D) By using the 'var' keyword. Show Answer Correct Answer: C) By using the 'global' keyword. 30. What will the following code output:for i in range(5, 10):print(i)? A) 5 6 7 8 9 10. B) 5 6 7 8 9. C) 10 9 8 7 6 5. D) 5 6 7 8. Show Answer Correct Answer: B) 5 6 7 8 9. 31. What does the special value None indicate when returned from a function? A) No value. B) An error has occurred. C) Both A and B. D) A successful operation. Show Answer Correct Answer: C) Both A and B. 32. Def mul ..... fun(a=10, b, c=1):return a+b+cis A) Correct. B) Incorrect. C) All the above. D) None of the above. Show Answer Correct Answer: B) Incorrect. 33. What is the purpose of the input function in the sums() function? A) To return a value. B) To display output. C) To define a function. D) To take user input. Show Answer Correct Answer: D) To take user input. 34. What is the output of the following piece of code?def test(i, j):if(i==0):return j else:return test(i-1, i+j) print(test(4, 7)) A) 17. B) Infinite Loop. C) 7. D) 13. Show Answer Correct Answer: A) 17. 35. What is a lambda function in Python? A) A function that is defined using the 'def' keyword. B) A small anonymous function that can have any number of arguments, but only one expression. C) A function that is used to create classes. D) A function that is used to handle exceptions. Show Answer Correct Answer: B) A small anonymous function that can have any number of arguments, but only one expression. 36. What is the purpose of the 'continue' 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 skip the current iteration and continue with the next iteration. Show Answer Correct Answer: D) To skip the current iteration and continue with the next iteration. 37. What is the correct way to define a function that takes no parameters? A) 'def myFunction:'. B) 'def myFunction{}'. C) 'def myFunction():'. D) 'def myFunction[]:'. Show Answer Correct Answer: C) 'def myFunction():'. 38. What is the default step size in Python if it is not provided? A) 3. B) 2. C) 0. D) 1. Show Answer Correct Answer: D) 1. 39. What will be the output of the following Python expression? round(4.576) A) 4.6. B) 5. C) 4. D) 4.5. Show Answer Correct Answer: A) 4.6. 40. The function randint( ) returns random integers between low and high numbers? A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 41. How do you format a string using f-strings? A) Use 'string {variable}' without f-prefix. B) Concatenate strings using '+' operator for variables. C) Use f'string {variable}' to format a string with variables. D) Format strings with 'string.format(variable)' method. Show Answer Correct Answer: C) Use f'string {variable}' to format a string with variables. 42. The variable declared outside a function is called a global variable. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 43. What is the output of the following code? def draw ..... circle():circle(50); draw ..... circle() A) Draws a circle. B) Draws a square. C) Error. D) None. Show Answer Correct Answer: A) Draws a circle. 44. What is the difference between print() and return in a function? A) Print() gives output on the screen, return gives value back to the program. B) Both are the same. C) Print() is faster than return. D) Return only works with numbers. Show Answer Correct Answer: A) Print() gives output on the screen, return gives value back to the program. 45. In which part of memory does the system store the parameters and local variables of a function call? A) Heap. B) Stack. C) Both a and b. D) None of the above. Show Answer Correct Answer: B) Stack. 46. What are the benefits of using functions? A) Simpler code. B) Code reuse. C) Better testing and debugging. D) All of the above. Show Answer Correct Answer: D) All of the above. 47. What will happen if you call a function with fewer arguments than it requires and no default values are set? A) The function will run with missing values as zero. B) Python will raise a 'TypeError'. C) The function will ignore missing arguments. D) The function will return 'None'. Show Answer Correct Answer: B) Python will raise a 'TypeError'. 48. Which type of function definition allows specifying default values in the function header? A) Positional arguments. B) Named arguments. C) Default arguments. D) Keyword arguments. Show Answer Correct Answer: C) Default arguments. 49. What is the lifetime of a variable defined inside a function? A) Until the function ends. B) Until the program ends. C) Until the module is reloaded. D) Until the variable is deleted. Show Answer Correct Answer: A) Until the function ends. 50. 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'. 51. Parameters in a function are like: A) The computer screen. B) The name of the function. C) The input we give to the function. D) The result we get. Show Answer Correct Answer: C) The input we give to the function. 52. ..... 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(). 53. What is the syntax to define a function in Python? A) Function function name():. B) Def function name():. C) Define function name():. D) Create function name():. Show Answer Correct Answer: B) Def function name():. 54. 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. 55. 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: B) 'lambda x:x * x'. 56. What function is used to find the length of a string? A) Length(). B) Len(). C) Size(). D) Count(). Show Answer Correct Answer: B) Len(). 57. 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. 58. Which of the following is a keyword used to define a function in Python? A) 'func'. B) 'def'. C) 'function'. D) 'define'. Show Answer Correct Answer: B) 'def'. 59. 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 first argument to the filter() function. D) Pass the lambda function as the second argument to the filter() function. Show Answer Correct Answer: C) Pass the lambda function as the first argument to the filter() function. 60. Which of the following is NOT a reason to use functions? A) To make a program more self-documenting. B) To demonstrate intellectual superiority. C) To make a program more modular. D) To reduce code duplication. Show Answer Correct Answer: B) To demonstrate intellectual superiority. ← 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 4Class 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