首页 > 其他 > 详细

作业二

时间:2018-09-13 13:21:15      阅读:182      评论:0      收藏:0      [点我收藏+]
#温度转换
while True:
a = int(input("华氏温度转换为摄氏温度请按1\n摄氏温度转换为华氏温度请按2\n"))
if a ==1:
fahrenheit = float(input("请输入华氏温度:"))
#温度计算
celsius = (fahrenheit*1.8)+32
#输出温度
print("{}华氏温度转为摄氏温度为{}".format(celsius,fahrenheit));
elif a ==2:
fahrenheit = float(input(‘请输入摄氏温度‘))
celsius = 5/9*(fahrenheit - 32)
print(‘{}摄氏温度转换为华氏温度为:{}‘.format(fahrenheit,celsius));
else:
break;

技术分享图片

#数字竞猜
import random
secret = random.randint(1,10)
#输入数字
print(‘猜数字游戏‘)
guess = -2
while guess !=secret:
a = input(‘请输入数字:‘)
guess = int(a)
if guess > secret:
print(‘输入的数字太大了!‘)
elif guess < secret :
print(‘输入的数字太小了!‘)
else:
print(‘猜对了!‘)
print(‘游戏结束‘)

技术分享图片

#身份证号码提取
myid = ‘441225199609063246‘

age = 2018-int(myid[6:10])

if int(myid[-2])%2==0:
sex = ‘girl‘
else:
sex = "boy"
print(age,sex)

技术分享图片

#制作网址
for i in range(2,10):
print(‘http://news.gzcc.cn/html/xiaoyuanxinwen/‘+str(i)+‘.html‘)

技术分享图片

#学号提取
s = ‘201606050039‘
a = s[:4]
b = s[4:6]
c = s[6:8]
d = s[8:]
print(‘年纪{}‘.format(a))
print(‘学院{}‘.format(b))
print(‘班级{}‘.format(c))
print(‘学号{}‘.format(d))

技术分享图片

 





作业二

原文:https://www.cnblogs.com/SJMHJ/p/9639595.html

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