mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-09 08:16:58 +02:00
[python/en]...Added some info on division
This commit is contained in:
@@ -58,6 +58,12 @@ allow you to write Python 3 code that will run on Python 2, so check out the Pyt
|
|||||||
-5 // 3 # => -2
|
-5 // 3 # => -2
|
||||||
-5.0 // 3.0 # => -2.0
|
-5.0 // 3.0 # => -2.0
|
||||||
|
|
||||||
|
# Note that we can also import division module(Section 6 Modules)
|
||||||
|
# to carry out normal division with just one '/'.
|
||||||
|
from __future__ import division
|
||||||
|
11/4 # => 2.75 ...normal division
|
||||||
|
11//4 # => 2 ...floored division
|
||||||
|
|
||||||
# Modulo operation
|
# Modulo operation
|
||||||
7 % 3 # => 1
|
7 % 3 # => 1
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user