-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path7_if.py
More file actions
39 lines (32 loc) · 837 Bytes
/
7_if.py
File metadata and controls
39 lines (32 loc) · 837 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
39
# Conditionals of course
cars = ['audi','porshe','tesla','ferrari','mazda']
for c in cars:
if c == "tesla":
print ("tesla FTW!")
else:
print (c)
# Classic comparators
for n in range(5,25):
if n < 18:
print (str(n) + "= nope!")
if n == 18:
print (str(n) + "= yes!")
if n > 18:
print (str(n) + "= meh!")
# better comparations
for k in range(100,500, 50):
if k < 200:
print ("Too cheap")
elif k == 300:
print ("Good prize")
elif k > 300:
print ("what?")
# Lists and choises
pizza_tops = ['mushrooms', 'extra cheese']
if 'mushrooms' in pizza_tops:
print("Adding mushrooms.")
if 'pepperoni' in pizza_tops:
print("Adding pepperoni.")
if 'extra cheese' in pizza_tops:
print("Adding extra cheese.")
# Your pizza is ready sir!