# 如果。。。就。。。
print('1.')
if 1+1 == 2:
print('1+1是等于2的')
print('1+1还是等于2的')
print('1+1就等于2的')
print('2.上网案例')
age = 20
if age >= 18:
print('满足18岁')
print('开心上网')
print('3.input()')
age = input('请输入一个数字:') # 输入的是字符串
print(age)
print(type(age))
age_1 = int(input('请输入一个数字:')) # 输入的是字符串
print(age_1)
print(type(age_1))
print('4.上网案例2.0')
age = int(input('请输入年龄:'))
if age >= 18:
print('满足18岁')
print('开心上网')
print('5.上网案例3.0')
age = int(input('请输入年龄:'))
if age >= 18:
print('满足18岁')
print('开心上网')
else:
print('年龄未满18岁')
print('小朋友,赶快回家写作业')
print('6.工作年龄')
age = 80
if age < 18: # 当年龄小于18
print(f'你的年龄是{age},是童工')
elif age >= 18 and age <= 60: # 18 <= age <= 60
print(f'你的年龄是{age},是合法工作年龄')
else:
print(f'你的年龄是{age},退休年龄')
print('7.嵌套if')
print('坐公交车案例')
my_money = 10
seat = True # 有无空座位True False
if my_money >= 2: # 当my_money大于等于2时
print('土豪请上车')
if seat:
print('有空座位')
print('找个位置坐')
else:
print('站着')
else:
print('朋友,没带钱,跟着跑,跑快点')
print('今日练习')
t = int(input('请输入百分制成绩t:'))
if 90 <= t <= 100:
print('学生等级为A')
elif 80 <= t <= 89:
print('学生等级为B')
elif 70 <= t <= 79:
print('学生等级为C')
elif 60 <= t <= 69:
print('学生等级为D')
elif 0 <= t <= 59:
print('学生等级为E')
else:
print('数据超出范围!')
手机扫一扫
移动阅读更方便
你可能感兴趣的文章