This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Math”.
1. What is returned by math.ceil(3.4)?
a) 3
b) 4
c) 4.0
d) 3.0
View Answer
Explanation: The ceil function returns the smallest integer that is bigger than or equal to the number itself.
2. What is the value returned by math.floor(3.4)?
a) 3
b) 4
c) 4.0
d) 3.0
View Answer
Explanation: The floor function returns the biggest number that is smaller than or equal to the number itself.
3. What will be the output of print(math.copysign(3, -1))?
a) 1
b) 1.0
c) -3
d) -3.0
View Answer
Explanation: The copysign function returns a float whose absolute value is that of the first argument and the sign is that of the second argument.
4. What is displayed on executing print(math.fabs(-3.4))?
a) -3.4
b) 3.4
c) 3
d) -3
View Answer
Explanation: A negative floating point number is returned as a positive floating point number.
5. Is the output of the function abs() the same as that of the function math.fabs()?
a) sometimes
b) always
c) never
d) none of the mentioned
View Answer
Explanation: math.fabs() always returns a float and does not work with complex numbers whereas the return type of abs() is determined by the type of value that is passed to it.
6. What is the value returned by math.fact(6)?
a) 720
b) 6
c) [1, 2, 3, 6]
d) error
View Answer
Explanation: NameError, fact() is not defined.
7. What is the value of x if x = math.factorial(0)?
a) 0
b) 1
c) error
d) none of the mentioned
View Answer
Explanation: Factorial of 0 is 1.
8. What is math.factorial(4.0)?
a) 24
b) 1
c) error
d) none of the mentioned
View Answer
Explanation: The factorial of 4 is returned.
9. What will be the output of print(math.factorial(4.5))?
a) 24
b) 120
c) error
d) 24.0
View Answer
Explanation: Factorial is only defined for non-negative integers.
10. What is math.floor(0o10)?
a) 8
b) 10
c) 0
d) 9
View Answer
Explanation: 0o10 is 8 and floor(8) is 8.
More MCQs on Python Math:
Sanfoundry Global Education & Learning Series – Python.
To practice all areas of Python, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Information Technology Books
- Apply for Python Internship
- Practice Programming MCQs
- Check Python Books
- Apply for Programming Internship