猜年龄
‘‘‘
age_of_prinacl = 55 #定义校长年龄55岁
guess_age = int(input("guess_age = ")) #输入猜的年龄并转换为Int整数类型,因为Input都是字符串
if age_of_prinacl == guess_age: #后面要带冒号
print("恭喜你,答对了!") #必须缩进一行tab键
elif age_of_prinacl > guess_age: #否则如果,pyhton用elif
print("年龄偏小")
else: #必须带冒号
print("年龄偏大!") #必须缩进
‘‘‘
分数分类
‘‘‘
num = int(input("你的分数是:"))
if num > 90:
print("您的分数是A")
elif num > 80:
print("您的分数是B")
elif num > 60:
print("您刚及格")
else:
print("您的分数不及格")
‘‘‘
#取最大数
‘‘‘
a = int(input("a = "))
b = int(input("b = "))
c = int(input("c = "))
if a >= b:
tmp = a
else:
tmp = b
if tmp >= c:
tmp = tmp
else:
tmp = c
print(tmp)
‘‘‘
取最大数
a = int(input("a = "))
b = int(input("b = "))
c = int(input("c = "))
if a > b:
tmp = a
if tmp > c:
print("max_num = ",tmp)
else:
print("max_num = ",c)
else:
tmp = b
if tmp > c:
print("max_num = ",tmp)
else:
print("max_num = ",c)