LearnFrenzy
Sign in Take a free test

Variables and Data Types · Predict the Output · Question 8

Types produced by / and // Answer, explanation & discussion

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

What is the output of the following Python program?

main.py
print(type(10 / 2).__name__, 10 / 2, type(10 // 2).__name__, 10 // 2)
  • A int 5 int 5
  • B float 5.0 int 5 Correct
  • C float 5.0 float 5.0
  • D int 5.0 int 5
Correct Answer: Option B

True division (/) always returns a float, even when the result is whole. Floor division of two ints returns an int.

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