last year
王宇杰country asked

In Python, why does division give 5.0 instead of 5?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi 王宇杰,

In Python, the / operator always returns a float, so 25 / 5 becomes 5.0 even though it is a whole number.

If you want an integer result, use //:

print(25 // 5)  # 5

If you have more questions, I am here to help 😊

Python
This question was asked as part of the Getting started with Python course.