Python Questions and Answers – Math – 3

This set of Python Developer Interview Questions & Answers focuses on “Math – 3”.

1. What is the result of math.trunc(3.1)?
a) 3.0
b) 3
c) 0.1
d) 1
View Answer

Answer: b
Explanation: 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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: b
Explanation: math.e is the constant defined in the math module.
advertisement
advertisement

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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: b
Explanation: math.pow(a, b) returns a ** b.
advertisement

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

Answer: b
Explanation: 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)
View Answer

Answer: b
Explanation: The function returns one floating point number.
advertisement

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
View Answer

Answer: c
Explanation: The function takes only one argument.

Sanfoundry Global Education & Learning Series – Python.

To practice all developer interview questions on Python, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.