-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
66 lines (52 loc) · 1.24 KB
/
test.py
File metadata and controls
66 lines (52 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import math
_tuple = (1, 2, 3, 4, 5)
print(type(_tuple))
print(_tuple[0])
print(_tuple[1])
print(_tuple[2])
print(type(_tuple[1]))
print('x = %d' % _tuple[0])
exit()
_str = 'AVc'
_str.capitalize()
_str = _str.strip('c')
print(_str)
exit(1)
_list = [1, 2, 3, 5, 6, 78, 11]
print(_list[1: -1])
_str = ''
print(_str[1:-1])
min = min(_list)
max = max(_list)
print(min, max)
def findminmax(L):
_min = L[0]
print(_min)
_max = L[0]
for val in L:
if val < _min:
_min = val
elif val > _max:
_max = val
return _min, _max
print(findminmax(_list))
for list_val in _list:
print(list_val)
for list_key, list_val in enumerate(_list): # 同时迭代索引和元素本身
print(list_key, list_val)
for tuple_val_1, tuple_val_2 in [(1, 2), (3, 4)]:
print(tuple_val_1, tuple_val_2)
for list_val_1, list_val_2 in [[5, 6], [3, 4]]:
print(list_val_1, list_val_2)
for dict_key in {'a': 'b'}:
print(dict_key)
for dict_val in {'a': 'b'}.values():
print(dict_val)
for dict_key, dict_val in {'a': 'b'}.items():
print(dict_key, dict_val)
def move(x, y, step, angle=0):
nx = x + step * math.cos(angle)
ny = y - step * math.sin(angle)
return nx, ny
x, y = move(1, 2, 3)
print(x, y)