forked from techstay/python-study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollflow.py
More file actions
39 lines (32 loc) · 697 Bytes
/
controllflow.py
File metadata and controls
39 lines (32 loc) · 697 Bytes
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
print('--------------if语句--------------')
i = 5
if i <= 3:
print('1<=3 is true')
elif 4 <= i <= 5:
print('4<=i<=5 is false')
else:
print('others')
print('--------------while语句--------------')
it = 0
sum = 0
while it <= 10:
sum += it
it += 1
print(f'sum={sum}')
print('--------------for语句--------------')
for i in range(1, 10):
print(i, end=' ')
print()
print('--------------for语句--------------')
it = 1
while it < 3:
it += 1
else:
print(f'else: it={it}')
print('--------------跳转语句--------------')
for i in range(1, 5):
for j in range(1, i + 1):
if (i <= j):
continue
print(f'[{i},{j}]',end='')
print()