summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSrinivas Gorur-Shandilya <github@srinivas.gs>2016-10-20 09:57:55 -0400
committerven <vendethiel@hotmail.fr>2016-10-20 15:57:55 +0200
commit8905c0c5bc7f6a7947a4fd0bcef8cf085ed08366 (patch)
tree2a6a1b9310b462e2cb365f36e66dd3f7fb6f1c61
parent0c6b3e73374064d3e2c5a149608c4213ca2068d8 (diff)
[python3] updated docs on division for python3 (#2473)
* updated docs on division for python3 prev. docs were confusing, did not show how to actually divide. * modified language about python division * fixed grammar
-rw-r--r--python3.html.markdown10
1 files changed, 7 insertions, 3 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index 341f0a39..43e90299 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -38,7 +38,7 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea
8 - 1 # => 7
10 * 2 # => 20
-# Except division which returns floats, real numbers, by default
+# Except division which defaults to rounding down
35 / 5 # => 7.0
# Result of integer division truncated down both for positive and negative.
@@ -47,8 +47,12 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea
-5 // 3 # => -2
-5.0 // 3.0 # => -2.0
-# When you use a float, results are floats
-3 * 2.0 # => 6.0
+# When one of the inputs is a float, result is 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