From 57036f128f5e874116729e67d8a77cd763f206d5 Mon Sep 17 00:00:00 2001 From: Evgeniy Ginzburg Date: Tue, 5 Aug 2014 17:41:28 +0300 Subject: aded negative integer division --- python3.html.markdown | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python3.html.markdown b/python3.html.markdown index bc0c05bd..de6d552a 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -38,9 +38,11 @@ Note: This article applies to Python 3 specifically. Check out the other tutoria # Except division which returns floats by default 35 / 5 # => 7.0 -# Truncation or Integer division +# Result of integer division truncated down both for positive and negative. 5 // 3 # => 1 5.0 // 3.0 # => 1.0 +-5 // 3 # => -2 +-5.0 // 3.0 # => -2.0 # When you use a float, results are floats 3 * 2.0 # => 6.0 @@ -51,7 +53,6 @@ Note: This article applies to Python 3 specifically. Check out the other tutoria # Enforce precedence with parentheses (1 + 3) * 2 # => 8 - # Boolean values are primitives True False @@ -60,7 +61,6 @@ False not True # => False not False # => True - # Equality is == 1 == 1 # => True 2 == 1 # => False @@ -79,7 +79,6 @@ not False # => True 1 < 2 < 3 # => True 2 < 3 < 2 # => False - # Strings are created with " or ' "This is a string." 'This is also a string.' -- cgit v1.2.3 From daf83c91232a259eee4cadef5f28210b7c83316d Mon Sep 17 00:00:00 2001 From: Evgeniy Ginzburg Date: Wed, 6 Aug 2014 23:43:37 +0300 Subject: aded negative integer division same as in python3 --- python.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python.html.markdown b/python.html.markdown index b7d5895a..312e3c15 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -45,9 +45,11 @@ to Python 2.x. Look for another tour of Python 3 soon! 2.0 # This is a float 11.0 / 4.0 # => 2.75 ahhh...much better -# Truncation or Integer division +# Result of integer division truncated down both for positive and negative. 5 // 3 # => 1 5.0 // 3.0 # => 1.0 # works on floats too +-5 // 3 # => -2 +-5.0 // 3.0 # => -2.0 # Modulo operation 7 % 3 # => 1 -- cgit v1.2.3 From 7bcf65278c28cffd32ef051965c2e6401563acc9 Mon Sep 17 00:00:00 2001 From: Evgeniy Ginzburg Date: Wed, 6 Aug 2014 23:45:37 +0300 Subject: comment about floats in integer division --- python3.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python3.html.markdown b/python3.html.markdown index 6e901b6a..dc972196 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -40,7 +40,7 @@ Note: This article applies to Python 3 specifically. Check out the other tutoria # Result of integer division truncated down both for positive and negative. 5 // 3 # => 1 -5.0 // 3.0 # => 1.0 +5.0 // 3.0 # => 1.0 # works on floats too -5 // 3 # => -2 -5.0 // 3.0 # => -2.0 -- cgit v1.2.3