This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 5 Functions In Python – Quiz 7 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 5 Functions In Python Quiz 7 (44 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. 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) []. 2. What is a local variable? A) A variable that is assigned a value inside a function. B) A variable that is global. C) A variable that can be accessed anywhere in the program. D) A variable that cannot be changed. Show Answer Correct Answer: A) A variable that is assigned a value inside a function. 3. 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. 4. Which keyword is used to send a value back from a function in Python? A) 'return'. B) 'output'. C) 'send'. D) 'yield'. Show Answer Correct Answer: A) 'return'. 5. 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. 6. 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. 7. What is the output of the following code? "'pythoncount = 0def increment():global count count += 1increment()print(count) "' A) '0'. B) '1'. C) 'Error'. D) 'count'. Show Answer Correct Answer: B) '1'. 8. 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. 9. Which keyword marks the beginning of the function block A) Def. B) Function. C) Func. D) Define. Show Answer Correct Answer: A) Def. 10. What is the scope of variables declared at the top level of a module or directly in the interpreter? A) Mutable scope. B) Local scope. C) Global scope. D) Immutable scope. Show Answer Correct Answer: C) Global scope. 11. Can a function call itself in Python? If yes, what is it called? A) Iteration. B) Repetition. C) Recursion. D) Looping. Show Answer Correct Answer: C) Recursion. 12. Which of the following statements is true about functions in Python? A) Functions can be defined inside other functions. B) Functions must always return a value. C) Functions cannot have default parameter values. D) Functions cannot return multiple values. Show Answer Correct Answer: A) Functions can be defined inside other functions. 13. 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-1)*(num-2). B) Num*fact(num-1). C) Num*(num-1). D) Fact(num)*fact(num-1). Show Answer Correct Answer: B) Num*fact(num-1). 14. 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. 15. 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. 16. 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. 17. Which type of loop in Python is used when a set of statements needs to be executed repeatedly based on a condition? A) Do-while loop. B) While loop. C) For loop. D) Nested loop. Show Answer Correct Answer: B) While loop. 18. What is the syntax for a function with required arguments? A) Def greet(name='Guest'):return 'Hello, ' + name. B) Def add(a, b):return a + b. C) Def student details(name, age):return f'Name:{name}, Age:{age}'. D) Def total marks(*marks):return sum(marks). Show Answer Correct Answer: B) Def add(a, b):return a + b. 19. How do you access the first character of a string? A) Retrieve the first character using string.slice(1, 2). B) Use string[0] to access the first character of a string. C) Use string.first() to get the first character. D) Access the first character with string.charAt(1). Show Answer Correct Answer: B) Use string[0] to access the first character of a string. 20. Python passes arguments to function by A) Reference. B) Value. C) Both. D) None of the above. Show Answer Correct Answer: C) Both. 21. What function can be used to split a string into a list? A) Split(). B) Cut(). C) Divide(). D) Break(). Show Answer Correct Answer: A) Split(). 22. 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. 23. 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. 24. Divya wants to print the identity of the object used in the function. Which of the following functions is used to print the same? A) Idy(). B) Id(). C) Ide(). D) Identity(). Show Answer Correct Answer: B) Id(). 25. Which of the following describes a user-defined function? A) Created by the user. B) Part of the Python library. C) None of the above. D) Automatically generated. Show Answer Correct Answer: A) Created by the user. 26. Which of the following is true about the 'not in' operator? A) Checks if a value is not present in a sequence. B) Is used to define a loop. C) Checks if a value is present in a sequence. D) Is used to create a function. Show Answer Correct Answer: A) Checks if a value is not present in a sequence. 27. What is the name given to that area of memory, where the system stores the parameters and local variables of a function call? A) A stack. B) A heap. C) Storage area. D) An array. Show Answer Correct Answer: A) A stack. 28. What is the output of the following code? "'pythondef greet():return "Hello!"print(greet()) "' A) 'greet'. B) 'Hello!'. C) 'None'. D) 'print'. Show Answer Correct Answer: B) 'Hello!'. 29. What is the syntax for calling a function in Python? A) FunctionName{};. B) FunctionName[]. C) Function name(). D) FunctionName{}. Show Answer Correct Answer: C) Function name(). 30. What is a standard module in Python? A) A standard module is a user-defined module. B) A standard module is a third-party library. C) A standard module is a type of Python script. D) A standard module in Python is a module included in the Python standard library. Show Answer Correct Answer: D) A standard module in Python is a module included in the Python standard library. 31. Which type of function is a separate file containing functions and variables? A) Pre-defined Functions. B) Built-in Functions. C) User-defined Functions. D) Modules. Show Answer Correct Answer: D) Modules. 32. For a function header as follows:def Calc(X, Y = 20):Which of the following function calls will give an error? A) Calc(Y = 25). B) Calc(X = 15, Y = 25). C) Calc(X = 25). D) Calc(15, 25). Show Answer Correct Answer: A) Calc(Y = 25). 33. What does the 'return' statement in a function allow you to do? A) Print a value to the console. B) Terminate the function execution. C) Define a new variable. D) Return a value or an expression. Show Answer Correct Answer: D) Return a value or an expression. 34. What will the following code output? def greet(name):print('Hello', name); greet('Alice') A) Hello Alice. B) Error. C) Alice. D) Hello. Show Answer Correct Answer: A) Hello Alice. 35. Which of the following is a valid way to pass parameters to a function in Python? A) 'def myFunction{x, y}:'. B) 'def myFunction[x, y]:'. C) 'def myFunction:'. D) 'def myFunction(x, y):'. Show Answer Correct Answer: D) 'def myFunction(x, y):'. 36. Function sqrt() is available under which module of python? A) Random. B) Math. C) Statistics. D) None of the above. Show Answer Correct Answer: B) Math. 37. How can you create a copy of a list in Python? A) List.clone(). B) Copy.list(). C) Copy(). D) List.copy(). Show Answer Correct Answer: D) List.copy(). 38. What will be printed by the following code? "'pythondef print ..... message(msg):print(msg)result = print ..... message("Hello, Year 11!")print(result) "' A) 'Hello, Year 11!' followed by 'None'. B) 'Hello, Year 11!' followed by 'Hello, Year 11!'. C) 'None' only. D) 'Hello, Year 11!' only. Show Answer Correct Answer: A) 'Hello, Year 11!' followed by 'None'. 39. Which is the most appropriate definition for recursion? A) A function that calls itself. B) A function execution instance that calls another execution instance of the same function. C) A class method that calls another class method. D) An in-built method that is automatically called. Show Answer Correct Answer: B) A function execution instance that calls another execution instance of the same function. 40. A(n) ..... is the part of a program in which a variable may be accessed. A) Area of visibility. B) Loop. C) Scope. D) Declaration space. Show Answer Correct Answer: C) Scope. 41. Which function is called anonymous unnamed function A) Lambda. B) Define. C) Function. D) Recursion. Show Answer Correct Answer: A) Lambda. 42. Can a lambda function have multiple arguments in Python? A) Sometimes. B) Only if it is defined as a named function. C) No. D) Yes. Show Answer Correct Answer: D) Yes. 43. When a variable is inside of a function what do you call its scope? A) Global. B) Boolean. C) Static. D) Local. Show Answer Correct Answer: D) Local. 44. If you want to remove and return the last element of a list, which method would you use? A) Clear(). B) Remove(). C) Index(). D) Pop(). Show Answer Correct Answer: D) Pop(). ← PreviousRelated 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 5Class 11 Computer Science Chapter 5 Functions In Python Quiz 6Class 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