0910作业
2018-09-10 11:17 PM的世代 阅读(224) 评论(0) 编辑 收藏 举报温度转换
while True: a = int(input("摄氏度转华氏度按1\n华氏度转摄氏度按2\n" )) if a == 1: S = float(input("输入摄氏度:")) H = (S * 9 / 5) + 32 print("%0.1f 摄氏度转华氏度为 %0.1f" % (S, H)) elif a == 2: H = float(input("请输入华氏度: ")) S = 32+(H * 1.8) print("%0.1f 华氏度转摄氏度为 %0.1f" % (S, H)) else: break
数字猜谜
number = 19 guess = -1 print("数字猜谜游戏!") while guess != number: guess = int(input("请输入你猜的数字: ")) if guess == number : print("恭喜,你猜对了!") elif guess < number : print("猜的数字小了") elif guess > number : print("猜的数字大了")
身份证与学号
a = "201606050026" print("年级:{}\n专业:{}\n班级:{}\n序号:{}".format(a[-12:-8],a[-8:-6],a[-6:-4],a[-4:])) s = "445222199711203557" print("出生市区:{}\n出生日期:{}\n性别:{}".format(s[2:6],s[6:14],s[16]))
字符串的操作
name = input("请输入一个名字:") print(name + "请按时交作业!"*3)
一系列的网址
print("http://news.gzcc.cn/html/xiaoyuanxinwen/index.html") for i in range(2,243): print('http://news.gzcc.cn/html/xiaoyuanxinwen/' + str(i) + '.html')