classification
Title: Docs example: converting mixed types to floating point
Type: Stage:
Components: Documentation Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Mariatta, MihaiHimself, docs@python, terry.reedy
Priority: low Keywords: easy

Created on 2017-05-14 09:08 by MihaiHimself, last changed 2017-05-21 20:57 by gfyoung.

Pull Requests
URL Status Linked Edit
PR 1701 open gfyoung, 2017-05-21 20:57
Messages (2)
msg293641 - (view) Author: Mihai Borobocea (MihaiHimself) Date: 2017-05-14 09:08
Section 3.1.1 in the Docs states:
"operators with mixed type operands convert the integer operand to floating point"
https://docs.python.org/3/tutorial/introduction.html

But gives an example using the division operator:
>>> 3 * 3.75 / 1.5
7.5
>>> 7.0 / 2
3.5

In Python 3, division always returns a float, e.g. when all operands are integers:
>>> 3 * 3 / 1
9.0
>>> 7 / 2
3.5

To illustrate that "operators with mixed type operands convert the integer operand to floating point" the example should not use division. For example:
>>> 3 * 3.75 - 1
10.25
>>> 7.0 + 2
9.0
msg293967 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-19 19:18
Agreed.  Also, I think one example is enough.  A good sprint fix.
History
Date User Action Args
2017-05-21 20:57:02gfyoungsetpull_requests: + pull_request1797
2017-05-19 19:18:32terry.reedysetkeywords: + easy
nosy: + terry.reedy
messages: + msg293967

2017-05-14 13:45:04Mariattasetpriority: normal -> low
assignee: docs@python -> Mariatta

nosy: + Mariatta
2017-05-14 09:08:39MihaiHimselfcreate