Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.4k points)

Why does “5/2 = 2” and not 2.5 in Python?

1 Answer

0 votes
by (27.5k points)

Well it is mainly because of integer division. But if you use Python 3.x, you will get your desired output. Python 3.x, automatically takes both numerator and denominator as float, when you are perform divisions but Python 2.x takes it as you've defined earlier.

Find out more interesting facts about Python in this Python tutorial series

You can also go ahead and start coding by referring to this well structured video. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jan 5, 2021 in Python by ashely (50.2k points)
0 votes
1 answer

Browse Categories

...