首页 > 其他 > 详细

day_04_if...else/input/print/

时间:2018-01-12 00:29:07      阅读:236      评论:0      收藏:0      [点我收藏+]

猜年龄
‘‘‘
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)

day_04_if...else/input/print/

原文:https://www.cnblogs.com/yiran2009/p/8271281.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!