diff options
author | Foo Chuan Wei <foochuanwei@users.noreply.github.com> | 2016-11-09 13:16:06 -0500 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-11-09 19:16:06 +0100 |
commit | e837e25a70384d33fc3083d9f2382c31591f548e (patch) | |
tree | 9a135f286283ae206773842da93571b61720cf3f | |
parent | 6b770a3e5fe7a1db2c87392565fcf4de96ffcfb7 (diff) |
[python3/en] Edit python3 division (#2560)
The result of division is always a float.
e.g.
35/5 = 7.0
10 / 3 = 3.3333333333333335
10.0 / 3 = 3.3333333333333335
10 / 3.0 = 3.3333333333333335
-rw-r--r-- | python3.html.markdown | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/python3.html.markdown b/python3.html.markdown index 9ce7790b..839d66fd 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -37,8 +37,6 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea 1 + 1 # => 2 8 - 1 # => 7 10 * 2 # => 20 - -# Except division which defaults to rounding down 35 / 5 # => 7.0 # Result of integer division truncated down both for positive and negative. @@ -47,13 +45,9 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea -5 // 3 # => -2 -5.0 // 3.0 # => -2.0 -# When one of the inputs is a float, result is a float +# The result of division is always a float 10.0 / 3 # => 3.3333333333333335 -# to force this behavior on integers, use -from __future__ import division -10 / 3 # => 3.3333333333333335 - # Modulo operation 7 % 3 # => 1 |