-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples2.py
More file actions
171 lines (122 loc) · 2.81 KB
/
examples2.py
File metadata and controls
171 lines (122 loc) · 2.81 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
x = 22
if x >= 0 and x <= 20:
print('True')
print('------------------------')
y = 2
if y == 1 or y == 2 or y == 3:
print('valid')
print('------------------------')
a = 2
b = 4
if a > b: print('a is greater than b')
print('------------------------')
name = 'Ali'
job = 'Developer'
if name == 'Ali':
print('Name: Ali')
if job == 'Developer':
print('Nice')
print('-------------------------')
a = 33
b = 33
if b > a:
print('b is greater than a')
elif a == b:
print('a and b are equal')
print('-------------------------')
sex = 'Female'
age = 30
if sex == 'male':
print('Gender: male')
if age <= 31:
print('he is a young boy')
elif sex == 'Female':
print('Gender: female')
if age >= 21:
print('she is a young girl')
print('--------------------------')
sex = 'Female'
age = 30
if sex == 'male':
if age <= 31:
print('he is a young boy')
elif sex == 'Female':
print('Gender: female')
if age >= 21:
print('she is a young girl')
print('----------------------------')
num = -3
if num >= 0:
if num == 0:
print('0')
else:
print('Positiv number')
else:
print('Negativ number')
print('----------------------------')
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num)
print('----------------------------')
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
print('----------------------------')
days = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
for day in days:
print(day)
print('----------------------------')
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
if x == "banana":
break
print('----------------------------')
days = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
for day in days:
print(day)
if day == "Monday":
break
print('----------------------------')
fruits = ["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
continue
print(x)
print('----------------------------')
days = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
for day in days:
if day == "Monday":
continue
print(day)
print('----------------------------')
numbers = [1, 2, 3, 4, 5]
for x in numbers:
print(x)
else:
print("Finally finished")
print('----------------------------')
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]
for x in adj:
for y in fruits:
print(x, y)
print('----------------------------')
i = 0
while i < 6:
print(i)
i += 1
print('----------------------------')
i = 0
while i < 6:
i += 1
if i == 3:
continue
print(i)
print('----------------------------')
i = 1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")