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
| #选择结构.py #单分支结构 ''' s=float(input("请输入成绩:")) if s>=60: print("合格") ''' #双分支结构 ''' s=float(input("请输入成绩:")) if s>=60: print("合格") else: print("不合格") print("运行结束") ''' #多分支结构 s=float(input("请输入成绩:")) if s>=90: print("优秀") elif s>=75: print("良好") elif s>=60: print("合格") else: print("不合格") print("运行结束") #案例1 s=float(input("请输入消费金额:")) if s>=10000: print("支付金额",s*0.7) elif s>=8000: print("支付金额",s*0.8) elif s>=6000: print("支付金额",s*0.9) else: print("支付金额",s) print("运行结束") #案例2 import random as rd x,y,z=rd.randint(30,50),rd.randint(30,50),rd.randint(30,50) print(x,y,z) a,b,c=eval(input("输入数字🔢:")) if a==x and b==y and c==z: print("很荣幸能够看到现在的樂乐") elif a==x and b==y or b==y and c==z or a==x and c==z: print("很幸运能再次遇见瑾昀") elif a==x or b==y or c==z: print("无他,仅能通过瑾谦博客的方式来记录回忆") else: print("很遗憾,瑾已擦肩而过╮( •́ω•̀ )╭")
|