1 #python中只有if--else这一种判断方法 2 age = int(input('请输入你的年龄:')) 3 if age >= 18: 4 print('你是成年人了') 5 else: 6 print('你还是个宝宝')
C:ProgramDataAnaconda3python.exe E:/cnz/day1/条件判断.py 请输入你的年龄:1 你还是个宝宝 Process finished with exit code 0
#分数判断
1 score = int(input('请输入你的分数:')) 2 if score >= 90: 3 print('优秀') 4 elif score >= 80 and score < 90: 5 print('良好') 6 elif score >=60 and score < 80: 7 print('及格') 8 else: 9 print('不及格')
C:ProgramDataAnaconda3python.exe E:/cnz/day1/条件判断.py 请输入你的分数:85 良好 Process finished with exit code 0