Python Modules MCQs | 25 Practice Questions with Answers | CBSE Class 11 Computer Science
Class 11 · Computer Science
Python Modules MCQs (25 Questions)
Practice these multiple-choice questions to strengthen your understanding of Python Modules. Click Show Answer to reveal the correct answer and explanation.
Q1. What is a Python module?
A. A loop
B. A function
C. A file containing Python code
D. A variable
Show Answer
Answer: C. A file containing Python code
Explanation: A module is a Python file containing reusable functions, variables, classes, and constants.
Q2. Which statement is used to import an entire module?
A. include math
B. import math
C. using math
D. load math
Show Answer
Answer: B. import math
Explanation: The import statement imports an entire module.
Q3. Which statement imports only the sqrt() function from the math module?
A. import sqrt
B. from math import sqrt
C. import math.sqrt
D. using math.sqrt
Show Answer
Answer: B. from math import sqrt
Explanation: The from ... import ... statement imports only the required function.
Q4. Which module provides mathematical functions such as sqrt() and pow()?
A. random
B. statistics
C. math
D. os
Show Answer
Answer: C. math
Explanation: The math module provides mathematical constants and functions.
Q5. Which constant represents the value of π (Pi)?
A. math.pi
B. math.e
C. math.pow
D. math.sqrt
Show Answer
Answer: A. math.pi
Explanation: math.pi stores the value of Pi.
Q6. Which function returns the square root of a number?
A. math.pow()
B. math.sqrt()
C. math.fabs()
D. math.floor()
Show Answer
Answer: B. math.sqrt()
Explanation: The math.sqrt() function returns the square root of a given number.
Q7. Which function rounds a number upward to the nearest integer?
A. floor()
B. ceil()
C. round()
D. fabs()
Show Answer
Answer: B. ceil()
Explanation: math.ceil() returns the smallest integer greater than or equal to the given number.
Q8. Which function rounds a number downward to the nearest integer?
A. ceil()
B. floor()
C. fabs()
D. pow()
Show Answer
Answer: B. floor()
Explanation: math.floor() returns the largest integer less than or equal to the given number.
Q9. Which function returns the absolute value of a number?
A. pow()
B. fabs()
C. sqrt()
D. ceil()
Show Answer
Answer: B. fabs()
Explanation: math.fabs() returns the absolute (positive) value of a number.
Q10. Which function calculates the value of x raised to the power y?
A. power()
B. exp()
C. math.pow()
D. sqrt()
Show Answer
Answer: C. math.pow()
Explanation: math.pow(x,y) returns x raised to the power y.
Q11. Which function returns the sine of an angle (in radians)?
A. math.cos()
B. math.tan()
C. math.sin()
D. math.sqrt()
Show Answer
Answer: C. math.sin()
Explanation: The math.sin() function returns the sine of an angle measured in radians.
Q12. Which function returns the cosine of an angle (in radians)?
A. math.cos()
B. math.sin()
C. math.tan()
D. math.pow()
Show Answer
Answer: A. math.cos()
Explanation: The math.cos() function calculates the cosine of an angle in radians.
Q13. Which function returns the tangent of an angle (in radians)?
A. math.floor()
B. math.sin()
C. math.cos()
D. math.tan()
Show Answer
Answer: D. math.tan()
Explanation: The math.tan() function returns the tangent of an angle in radians.
Q14. Which module is used to generate random numbers in Python?
A. math
B. random
C. statistics
D. os
Show Answer
Answer: B. random
Explanation: The random module provides functions to generate random numbers.
Q15. Which function returns a random floating-point number between 0.0 and 1.0?
A. randint()
B. randrange()
C. random()
D. choice()
Show Answer
Answer: C. random()
Explanation: The random() function returns a random float greater than or equal to 0.0 and less than 1.0.
Q16. Which function returns a random integer between two specified values (both inclusive)?
A. random()
B. randint()
C. randrange()
D. range()
Show Answer
Answer: B. randint()
Explanation: The randint(start,end) function returns a random integer including both the start and end values.
Q17. Which function returns a random number from a specified range?
A. random()
B. randint()
C. randrange()
D. range()
Show Answer
Answer: C. randrange()
Explanation: The randrange() function returns a randomly selected number from a given range.
Q18. Which module provides functions such as mean(), median(), and mode()?
A. random
B. statistics
C. math
D. decimal
Show Answer
Answer: B. statistics
Explanation: The statistics module is used to perform statistical calculations.
Q19. Which function returns the arithmetic average of a set of numbers?
A. median()
B. mode()
C. mean()
D. average()
Show Answer
Answer: C. mean()
Explanation: The mean() function returns the arithmetic average of numeric values.
Q20. Which function returns the middle value of an ordered data set?
A. mode()
B. average()
C. median()
D. mean()
Show Answer
Answer: C. median()
Explanation: The median() function returns the middle value after arranging the data in order.
Q21. Which function returns the value that occurs most frequently in a data set?
A. mean()
B. median()
C. mode()
D. random()
Show Answer
Answer: C. mode()
Explanation: The mode() function returns the value that appears most frequently in the data.
Q22. Which of the following statements is correct?
A. randint() excludes both limits.
B. randrange() includes the stop value.
C. random() returns a floating-point number between 0.0 and 1.0.
D. random() always returns an integer.
Show Answer
Answer: C. random() returns a floating-point number between 0.0 and 1.0.
Explanation: The random() function generates a random float greater than or equal to 0.0 and less than 1.0.
Q23. What is the output of the following code?
from math import sqrt
print(sqrt(64))
A. 8
B. 64
C. 16
D. Error
Show Answer
Answer: A. 8
Explanation: The square root of 64 is 8.
Q24. Which of the following is a correct use of the statistics module?
A. statistics.random()
B. statistics.mean([10,20,30])
C. statistics.sqrt(25)
D. statistics.randint(1,10)
Show Answer
Answer: B. statistics.mean([10,20,30])
Explanation: The mean() function belongs to the statistics module and calculates the arithmetic average.
Q25. Which module is most suitable for calculating the average marks of students?
A. math
B. random
C. statistics
D. os
Show Answer
Answer: C. statistics
Explanation: The statistics module provides functions such as mean(), median(), and mode() for statistical calculations.
Answer Key
| Q.No. | Answer | Q.No. | Answer | Q.No. | Answer |
|---|---|---|---|---|---|
| 1 | C | 10 | C | 19 | C |
| 2 | B | 11 | C | 20 | C |
| 3 | B | 12 | A | 21 | C |
| 4 | C | 13 | D | 22 | C |
| 5 | A | 14 | B | 23 | A |
| 6 | B | 15 | C | 24 | B |
| 7 | B | 16 | B | 25 | C |
| 8 | B | 17 | C | ||
| 9 | B | 18 | B |
Practice Tips
- Remember the difference between
import moduleandfrom module import function. - Revise the important math module functions such as
sqrt(),pow(),ceil(),floor(),sin(),cos(), andtan(). - Understand the difference between
random(),randint(), andrandrange(). - Know when to use
mean(),median(), andmode()from thestatisticsmodule. - Practice writing small programs using different modules to strengthen your understanding.
- Attempt all questions without viewing the answers first, then check the explanations to identify concepts that need revision.