Python Learning-day06
Switch/case statements in 1.python
Python does not have a switch/case statement, you can use the dictionary and function in a way to achieve switch/case effect.
As follows:
Note: from__future__ Import Division: The function is to let the results of a decimal in the display of decimals, not rounding.
2. Built-in functions
(1) function:
ABS ()---------> return absolute value
Max ()--------> Max
Min ()---------> Take minimum value
Len ()--------> take length
Divmod ()------> Take mould
Example: Divmod (5,2)
Output: (2,1)
Pow (): POW (2,3)---->2 3 powers: 8
POW (2,3,4)----->2^3%4:0 (2 of 3 power)
Callable (): Tests whether a function can be called
Isinstance (): Determine the type of an object
CMP (): Compares two strings for equality (equals returns 0, unequal returns-1)
Range (): Generates a sequence (array)
Xrange (): Same as Range () for big Data Operations (higher efficiency)
Search by Help:
(2)string function:
Str.capitalize (): Capitalize first letter
Str.replace (): Replace
Str.split (): Split string
Import string: module (not commonly used)
(3) Sequence processing function:
Python Learning 06