LearnFrenzy
Sign in Take a free test

Modules and Packages · Predict the Output · Question 1

math.floor, ceil and sqrt Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What is the output of the following Python program?

main.py
import math
print(math.sqrt(16), math.floor(-2.5), math.ceil(-2.5), math.trunc(-2.5), math.pi > 3.14)
  • A 4.0 -3 -2 -2 True Correct
  • B 4 -2 -3 -2 True
  • C 4.0 -2 -2 -3 True
  • D 4.0 -3 -2 -3 False
Correct Answer: Option A

sqrt returns a float. floor goes down (-3), ceil goes up (-2), trunc goes toward zero (-2).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links