Day 11
Lesson 30
上节课学了if语句 这节课新加了elif (else if)和else 举个例子
if a > b:
print("a is bigger than b")
elif a < b:
print("a is smaller than b")
else:
print("a is equal to b")
假设a=2 b=10 他会一个一个下来判断 直到满足条件 输出
people = 35
chairs = 15
recliner = 40
if chairs > people:
print("We should use chairs")
elif chairs < people:
print("We should not use chairs")
else:
print("Hmm... We can't decide either...")
if recliner > chairs:
print("That's too much recliner!")
elif chairs < recliner:
print("Yeah we should take the recliners")
else:
print("We still can't decide...")
if people > recliner:
print("Alright just take the recliners!")
else:
print("Fine we'll not use anything then.")
Lesson 31
这个就是上一个if else的运用 可以自己设计一个~
sign = '>'
print("You are in a room with two doors, which door do you want to pick? 1 or 2?")
door1 = input(sign)
if door1 == "1":
print("You are facing a chocolate cake, what do you want to do?")
print("1. Eat all")
print("2. Take a look and walk away")
print("3. Take a little bit")
cake = input(sign)
if cake == "1":
print("It's poison! You're dead.")
elif cake == "2":
print("You're safe.")
else:
print("You felt sick...")
else:
print("You are facing a glass of juice, what do you want to do?")
print("1. Drink all")
print("2. Take a look and walk away")
print("3. Drink a little bit")
drink = input(sign)
if drink == "1":
print("It's too hot! You're dead.")
elif drink == "2":
print("You're safe")
else:
print("It's really hot, you're throat is hurt...")
Lesson 32
这课就是设置一个list 放进去内容 然后用for循环打印出来
junk_food = ['chips', 'ice-cream', 'chocolate']
for food in junk_food:
print("I got %s" %food)
empty = []
for i in range(0,6):
print("Adding %d in the list" %i)
好啦 今天的三课结束啦
Au revoir~