🖼 人工智能学习总目录

🖼 《Python编程_从入门到实践》小结及目录

本章知识小结:

  • 1、if - elif - else
  • 2、in 、 not in

主要是知道if条件判断是干什么就ok

If-elif-else

1
2
3
4
5
6
7
8
9
10
11
12
13
14
available_toppings = ['mushrooms', 'olives', 'green peppers',
'pepperoni', 'pineapple', 'extra cheese']

requested_toppings = ['mushrooms', 'french fries', 'extra cheese']

for requested_topping in requested_toppings:
if requested_topping in available_toppings:
print(f"Adding {requested_topping}.")
elif requested_topping not in available_toppings:
print(f"Sorry, we don't have {requested_topping}.")
else:
print(f"Wrong Infomation!!!")

print("\nFinished making your pizza!")