[issue30361] Docs example: converting mixed types to floating point

New submission from Mihai Borobocea: 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
---------- assignee: docs@python components: Documentation messages: 293641 nosy: MihaiHimself, docs@python priority: normal severity: normal status: open title: Docs example: converting mixed types to floating point versions: Python 3.6, Python 3.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- assignee: docs@python -> Mariatta nosy: +Mariatta priority: normal -> low _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Terry J. Reedy added the comment: Agreed. Also, I think one example is enough. A good sprint fix. ---------- keywords: +easy nosy: +terry.reedy _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Changes by G Young <gfyoung17@gmail.com>: ---------- pull_requests: +1797 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Terry J. Reedy added the comment: New changeset e405d4b8dfb8b497e1c3d1f0f8e28030040c165e by terryjreedy (gfyoung) in branch 'master': bpo-30361: Use better example for mixed-type operands (#1701) https://github.com/python/cpython/commit/e405d4b8dfb8b497e1c3d1f0f8e28030040... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Mariatta Wijaya added the comment: Thanks for merging the PR, Terry. Now it needs backport :) ---------- stage: -> backport needed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Terry J. Reedy added the comment: Go ahead. I don't care much either way. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- pull_requests: +1939 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- pull_requests: +1940 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Terry J. Reedy added the comment: New changeset d52f47a8f7794ee09151973a00d29c8612672e7a by terryjreedy (Mariatta) in branch '3.6': [3.6] bpo-30361: Use better example for mixed-type operands (GH-1701) (#1856) https://github.com/python/cpython/commit/d52f47a8f7794ee09151973a00d29c86126... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Terry J. Reedy added the comment: New changeset 03c7cfcd52be702957cc174f5cb2ce4c8be8bfca by terryjreedy (Mariatta) in branch '3.5': [3.5] bpo-30361: Use better example for mixed-type operands (GH-1701) (#1857) https://github.com/python/cpython/commit/03c7cfcd52be702957cc174f5cb2ce4c8be... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Terry J. Reedy added the comment: Just curious, what sprint? ---------- resolution: -> fixed stage: backport needed -> resolved status: open -> closed type: -> enhancement _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________

Mariatta Wijaya added the comment: Sorry, I don't know whether this was a sprint project or not.] Saw that the original PR has sprint label on it, I merely copied them over to the backport PRs. Thanks. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30361> _______________________________________
participants (4)
-
G Young
-
Mariatta Wijaya
-
Mihai Borobocea
-
Terry J. Reedy