0

According to the Python tutorial here https://docs.python.org/3/tutorial/introduction.html

this gives a floating point number:

>>> 17 / 3  # classic division returns a float
5.666666666666667

However, when I try it I get:

>>> 17 / 3
5

How come? FWIW, I'm using Python 2.7.10 on the Mac.

Snowcrash
  • 66,400
  • 60
  • 203
  • 323

2 Answers2

1

That behaviour changed between Python 2.7 and 3.

Hans
  • 46
  • 4
1

The answer is in the URL:

https://docs.python.org/3/tutorial/introduction.html
https://docs.python.org/2.7/tutorial/introduction.html

The URL you posted is for Python 3, but you are using Python 2.7.

There's a dropdown at the top of the page. You can select 2.7 from there to get the documentation for Python 2.7:

>>> 17 / 3  # int / int -> int
5
Arc676
  • 4,196
  • 3
  • 26
  • 41