Bläddra i källkod

Changing examples to make numbers clearer

Based on:

   ---------- Forwarded message ----------
   From: Horst JENS <horstjens@gmail.com>
   Date: Tue, Aug 28, 2012 at 3:02 PM
   Subject: suggestion for "byte of python 3.x" Operators and their usage
   To: swaroop@swaroopch.com

   Dear Swaroop,

   sadly your famous "byte of python wiki" does not re-sent me my
   password for the byte-of-python3.x wiki ( Username HorstJENS ).
   Probably beacause i changed my email adress.

   So i write you directly:

   This is a suggestion for the page:
   http://www.swaroopch.org/notes/Python_en:Operators_and_Expressions

   You wrote in the table explaining the math operators of python 3.x:

   /      Divide               Divide x by y
   4 / 3 gives 1.3333333333333333.
   //     Floor Division   Returns the floor of the quotient
   4 // 3 gives 1.
   %   Modulo              Returns the remainder of the division    8 % 3
   gives 2. -25.5 % 2.25 gives 1.5.

   While working on this page with a student ( 13, german speaker) i
   noticed that both the divide and the floor division operation return
   the result 1 in your examples. ( we also tested 4 %3 , also
   returning 1) This is not ideal as it makes it less clear what the
   floor division and what the modulo is.

   I suggest to use instead those examples:

   /  Divide               Divide x by y
  10 / 3 gives 3.3333333333333333.
   // Floor Division   Returns the floor of the quotient             10
   // 3 gives 3.
   % Modulo            Returns the remainder of the division    10%3 gives 1

   greetings,
  -Horst
Swaroop C H 12 år sedan
förälder
incheckning
0169420a63
1 ändrade filer med 3 tillägg och 3 borttagningar
  1. 3 3
      07-operators-expressions.md

+ 3 - 3
07-operators-expressions.md

@@ -55,19 +55,19 @@ the interpreter interactively. For example, to test the expression
 
 :   Divide x by y
 
-    `4 / 3` gives `1.3333333333333333`.
+    `13 / 3` gives `4.333333333333333`.
 
 `//` (floor division)
 
 :   Returns the floor of the quotient
 
-    `4 // 3` gives `1`.
+    `13 // 3` gives `4`.
 
 `%` (modulo)
 
 :   Returns the remainder of the division
 
-    `8 % 3` gives `2`. `-25.5 % 2.25` gives `1.5`.
+    `13 % 3` gives `1`. `-25.5 % 2.25` gives `1.5`.
 
 `<<` (left shift)