This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Using Python as a Calculator
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, dongjs, xtreak
Priority: normal Keywords:

Created on 2019-11-29 10:08 by dongjs, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg357637 - (view) Author: dongjs (dongjs) Date: 2019-11-29 10:08
>>> 17 / 3  # classic division returns a float
5.666666666666667

this example is error 

what i test is below

>>> 17.0 / 3
5.666666666666667
>>> 17 / 3
5
msg357639 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-11-29 11:19
Maybe you are looking for floor division?

https://docs.python.org/3.3/reference/expressions.html#binary-arithmetic-operations

> The / (division) and // (floor division) operators yield the quotient of their arguments. The numeric arguments are first converted to a common type. Division of integers yields a float, while floor division of integers results in an integer; the result is that of mathematical division with the ‘floor’ function applied to the result. Division by zero raises the ZeroDivisionError exception.

Python 3.8 

>>> 17 / 3
5.666666666666667
>>> 17.0 / 3
5.666666666666667
>>> 17 // 3
5
msg357647 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-11-29 17:57
If you're using Python 2.7 then that would explain what you're seeing. You can either upgrade to Python 3 or use `from __future__ import division` to get the result you're after.
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83120
2019-11-29 17:57:16brett.cannonsetstatus: open -> closed

nosy: + brett.cannon
messages: + msg357647

resolution: not a bug
stage: resolved
2019-11-29 11:19:39xtreaksetnosy: + xtreak
messages: + msg357639
2019-11-29 10:08:16dongjscreate