250+ TOP MCQs on Python Math and Answers

Python Developer Interview Questions & Answers on “Math – 3”.

1. What is the result of math.trunc(3.1)?
a) 3.0
b) 3
c) 0.1
d) 1
Answer: b
Clarification: The integral part of the floating point number is returned.

2. What is the output of print(math.trunc(‘3.1’))?
a) 3
b) 3.0
c) error
d) none of the mentioned
Answer: c
Clarification: TypeError, a string does not have __trunc__ method.

3. Which of the following is the same as math.exp(p)?
a) e ** p
b) math.e ** p
c) p ** e
d) p ** math.e
Answer: b
Clarification: math.e is the constant defined in the math module.

4. What is returned by math.expm1(p)?
a) (math.e ** p) – 1
b) math.e ** (p – 1)
c) error
d) none of the mentioned
Answer: a
Clarification: One is subtracted from the result of math.exp(p) and returned.

5. What is the default base used when math.log(x) is found?
a) e
b) 10
c) 2
d) none of the mentioned
Answer: a
Clarification: The natural log of x is returned by default.

6. Which of the following aren’t defined in the math module?
a) log2()
b) log10()
c) logx()
d) none of the mentioned
Answer: c
Clarification: log2() and log10() are defined in the math module.

7. What is returned by int(math.pow(3, 2))?
a) 6
b) 9
c) error, third argument required
d) error, too many arguments
Answer: b
Clarification: math.pow(a, b) returns a ** b.

8. What is output of print(math.pow(3, 2))?
a) 9
b) 9.0
c) None
d) None of the mentioned

Answer: b
Clarification: math.pow() returns a floating point number.

9. What is the value of x if x = math.sqrt(4)?
a) 2
b) 2.0
c) (2, -2)
d) (2.0, -2.0)
Answer: b
Clarification: The function returns one floating point number.

10. What does math.sqrt(X, Y) do?
a) calculate the Xth root of Y
b) calculate the Yth root of X
c) error
d) return a tuple with the square root of X and Y
Answer: c
Clarification: The function takes only one argument.

developer interview questions on Python,

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top