9.13 作业

1.温度转换

while True:
    a = int(input("华氏转摄氏,请按1\n 摄氏转华氏,请按2\n"))
    if a==1:
        # 用户请输入摄氏温度
        c = float(input("请输入华氏温度"))
        # 计算华氏温度
        d = (c*1.8)+32
        # 向用户输出华氏温度
        print("{}华氏温度是{}摄氏度".format(c,d))
    elif a==2:
        d1 = float(input("请输入摄氏温度"))
        c1=(d1-32)*5/9
        print("{}摄氏温度是{}华氏度".format(d1,c1))
    else:
        break;

 

 

2.猜数字游戏

import random
a = random.randint(10,50)
n = input('请输入数字')
if n.isdigit():
    n = int(n)
    if n==a:
        print('猜对了')
    elif n>a:
        print('你猜的数字大了')
    else:
        print('你猜的数字小了')
    print('这个数是:',a)
else:
    print('你输入的不是数字')

3.身份证解析

myid = '440100199703250024'

address= myid[0:6]
bir = myid[6:14]
sex=myid[14:17]
age= 2018-int(myid[6:10])
if int(myid[-2])%2 == 0:
    sex = 'girl'
else:
    sex = 'boy'
print('省市{}'.format(address))
print('出生年月{}'.format(bir))
print('性别{}'.format(sex))
print('年龄{}'.format(age))

 

5.用for循环产生一系列网址

for i in range(1,100):
    print('http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html'.format(i))
    

 

转载于:https://www.cnblogs.com/844115-l/p/9639624.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值