-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson9.py
More file actions
62 lines (53 loc) · 1 KB
/
lesson9.py
File metadata and controls
62 lines (53 loc) · 1 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
""" Python Control Statements """
"""
1. Break Statement
"""
fruits = ["apple", "banana", "cherry"]
for x in fruits:
if x == "cherry":
break
print(x)
for i in range(5):
if i ==3:
break
print(i)
subject="python"
for i in subject:
if i=='h':
break
print(i)
""" Break with while loop """
n=0
while n<=10:
print(n)
if n==5:
break
n+=1
""" Continue Statement """
# continue with for loop
name = "CaptainSDavid"
for i in name:
if i=='S':
continue
print(i, end='')
# continue with while loop
i=0
while i<10:
i=i+1
if (i==5):
continue
print(i)
print("we jumped 5")
"""
Pass - we use pass where the code will be written somewhere but not yet written in the program file
- pass is just a placeholder for 'we will add functionality later
"""
print(" --- pass --- ")
values = ['p','y','t','h','o','n']
for value in values:
pass
for i in range(0,5):
if i==3:
pass
print("This is pass block:",i)
print(i)