Python type conversion:
Code:
Function Description INT (X [, base]) converts X to an integer. Long (X [, base]) converts X to a long integer. Float (x) converts X to a floating point number. Complex (real [, imag]) creates a plural number STR (x) converts object X to a string Repr (x) converts object X to an expression string Eval (STR) is used to calculate a valid Python expression in a string and return an object. Tuple (s) converts the sequence s into a tuples List (s) converts sequence s into a list CHR (x) converts an integer to a character Unichr (x) converts an integer to a Unicode Character Ord (x) converts a character into its integer Hex (x) converts an integer into a hexadecimal string. Oct (x) converts an integer into an octal string |
Supported sequence operations:
Code:
Operation description S + R sequential join S * n, n * S n copies, n is an integer S % d string formatting (string only) S [I] Index S [I: J] Slice X in S, X not in S subordination For X in S: Iteration Len (s) Length Min (s) minimum element Max (s) maximum element S [I] = x is s [I] re-assigned S [I: J] = R: returns the list fragment value. Del s [I] deletes an element from the list. Del s [I: J] deletes a clip from the list. |
Numeric operation:
Code:
Python code X <y shifts left X> Y shift right X & Y X | Y by bit or X ^ y exclusive or) ~ X flip by bit X + Y plus X-y Subtraction X * y Multiplication X/y X // y floor Division X ** y multiplication (xy) X % Y modulo (x mod y) -X changes the symbol bit of the operand. + X does nothing. ~ X ~ X =-(x + 1) ABS (x) absolute value Divmod (x, y) returns (INT (x/y), X % Y) Pow (X, Y [, modulo]) returns (x ** y) x % modulo Round (x, [N]) Rounding, n is the number of decimal places X <Y is less X> Y is greater X = Y equals X! = Y is not equal to (same as <>) X> = y is greater than or equal X <= y is less than or equal |