Functions and Modules Quiz - CBSE Class 10 Computer Science
Free practice quiz: Functions and Modules (CBSE Class 10 Computer Science). 19 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 19 questions freeSample questions
What is the correct way to define a function in Python?
- function myFunc():
- def myFunc[]:
- def myFunc():
- function(myFunc)
Show answer
Answer: C. def myFunc():
In Python, functions are defined using the 'def' keyword followed by the function name and parentheses.
What is a module in Python?
- A library of functions
- A piece of code that is built-in
- A variable of type module
- A package manager
Show answer
Answer: A. A library of functions
A module is a file containing Python definitions and statements, functioning as a library of functions and definitions.
What returning type allows a function to return two values at once?
- list
- tuple
- dictionary
- set
Show answer
Answer: B. tuple
A function can return a tuple, allowing you to return multiple values at once.
When are function annotations evaluated?
- During function definition
- During function execution
- During module import
- They are not evaluated
Show answer
Answer: A. During function definition
Function annotations are evaluated at function definition time and stored in the function’s __annotations__ attribute.
What is the output of 'print(math.pow(2, 3))' if the math module is imported?
- 8.0
- 6
- 8
- 2**3
Show answer
Answer: A. 8.0
The 'pow' function in the math module returns a float. So, 'math.pow(2, 3)' will return 8.0.