The first chapter of Rapid transformation: basic knowledge
todivide and to
( Python3.0 Prior to 2.7 version)
>>> 1/2
==>0
evenly divisible, common division:
Solution 1:1.0/2.0 ==>0.5
Solution 2:from _future_ Import Division ==>0.5
mean divisible
>>>1//2
==>0
floating-point // floating-point number, the result is still evenly divisible
>>>1.0//2.0
==>0.0
Actual operation:
* * indicates a exponentiation
>>>-3**2
==>-9
>>> (-3) **2
==>9
The -3**2 is preceded by a minus sign, indicating that the precedence of the exponentiation is higher than the negation
To : Long integer
>>>10000000000000000
==>10000000000000000l
The number is too large to exceed the normal integer the scope of the representation, Python automatically converted to long integers. long integers and ordinary integers can be mixed.
Actual operation:
: Modules and cmath
>>>Import Math
>>>Math.floor (32.9)
==>32.0
a bit of a Java- guided package,Math.floor (32.9) converts floating-point 32.9 to integers.
>>>from math import sqrt
>>>sqrt (-1)
==> Value error:math Domain Error
The Math function cannot handle the square root of a negative number, and must use the cmath
>>>from cmath import sqrt
>>>sqrt (-1)
==>1j
Note: string str and repr
>>>Print repr (10000L)
==>10000l
>>>Print str (10000L)
==>10000
STR (): conversion to String type identification disappears
Repr(): Create a string (identical to the parameter)
": print string containing numbers ( string + number ) + ' number ', function with repr () Same
in:input and raw_input
Input(): What type of data are you knocking on ?
Raw_input (): No matter what the knock is, the string type "common"
Note-python Basic Tutorial (Second Edition) chapter I