LearnFrenzy
Sign in Take a free test

Variables and Data Types · Predict the Output · Question 3

int() versus round() Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

What is the output of the following Python program?

main.py
print(int(3.99), int(-3.99), round(2.5), round(3.5), round(-0.5))
  • A 3 -3 2 4 0 Correct
  • B 4 -4 3 4 -1
  • C 3 -4 3 4 0
  • D 3 -3 3 4 -1
Correct Answer: Option A

int() truncates toward zero. round() sends halves to the even neighbour: 2.5 → 2, 3.5 → 4, -0.5 → 0 (printed as 0).

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