摘要: 可以在if语句里面放if语句创建嵌套的决定 有多的选项,中间多写几个elif 就行 写一个小脚本冒险选择游戏 1 print("""You enter a dark room with two doors. 2 Do you go through door #1 or door#2?""") # 打 阅读全文
posted @ 2023-10-09 18:23 萹豆 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1 people = 30 2 cars = 40 3 trucks = 15 4 5 if cars > people: # 下面同时为 True, 也只会运行第一个为 True 的块 ,另外两个优先级依次低于if 6 print("We should take the cars.") # 第一个 阅读全文
posted @ 2023-10-09 12:58 萹豆 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 1 people = 20 2 cats = 30 3 dogs =15 4 5 if people < cats: 6 print("Too many cats! The world is doomed!") 7 8 if people > cats: 9 print("Not many cats 阅读全文
posted @ 2023-10-09 12:04 萹豆 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 知识点: 先找== != 运算真假 再运算括号内的逻辑真假 运算not 最后算括号外的and or 阅读全文
posted @ 2023-10-09 11:23 萹豆 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 逻辑关系: and 与 or 或 not 非 != 不等于 == 等于 >= 大于等于 <= 小于等于 True 真 False 假 真值表: not 真假 not False True not True False or 真假 True or False True True or True Tru 阅读全文
posted @ 2023-10-09 10:45 萹豆 阅读(6) 评论(0) 推荐(0) 编辑