Friday, February 1, 2013

Working with Numbers

1) Number Types: integers, long integers, floating-point numbers, and complex numbers

2) Basic Operators:
    x/y: quotient of x and y, if x and y are integers, result is rounded down
    x//y: floored quotient of x and y, use with floating-point numbers to return a decimal result identical to x/y if x and y  were integers
    x%y: remainder of x/y
    divmod(x,y): typle that is (x//y, x%y)
    pow(x,y) = x**y: x to the y power (x的y次方)

3) s.index(x): index of first x in s
    s.count(x): total occurrences of x in s
 

No comments:

Post a Comment