OK, let's continue.
- Conditional Judgments and Loop
- if
- if-else
- if-elif-else
- while
- for
- break
- continue
- multiple loop
- Differences between Dict and Set
- Dict: A kind of structure in the type of "Key-Value"
- described in "{}"
- formed by "key: value"
- function "len()" to calculate the length
- judge empty:① if 'key' in dict ②dict.get('key') ->if empty, return None automatically
- the key in dict is unchangeable
- Set: A kind of struture in the type of Non-repeating elements collection
- described in "set([,,,,])"
- add() to add elements
- remove() to delete elements
- Dict: A kind of structure in the type of "Key-Value"
- Functions
- where to searching functions: http://docs.python.org/2/library/functions.html#abs
- some common functions: abs(), cmp(), int(), str(), sum()
- the Return Value of Functions
A function can return single value, as well as return more value. But in essence it returns one, a tuple. The function treats the values as a tuple.
代码语言:javascript复制1 >>> r = move(100, 100, 60, math.pi / 6)
2 >>> print r
3 (151.96152422706632, 70.0)
-
- recursive functions: take care of overflowing
- default parameter: set default parameter in the function line in the blankets, and the default parameter must be set at the right side
- variable parameter: use '*' to mark variable parameter , and they are regarded as a tuple