练习二

while True:
    a=int(input("摄氏转华氏请按1\n华氏转摄氏请按2\n"))
    if a == 1:
        # 用户输入摄氏温度
        ce=float(input('输入摄氏温度:'))
        # 计算华氏温度
        fa = (ce * 1.8) + 32
        # 向用户输出华氏温度
        print('{:.2f}摄氏转华氏为:{:.2f}'.format(fa,ce))
    else:
        fa=float(input('请输入华氏温度:'))
        ce = 5 / 9 * (fa - 32)
        # 计算摄氏温度
        print('{:.2f}华氏转摄氏为:{:.2f}\n'.format(fa, ce))

import random
sc = random.randint(1,5)
z=int(input('请输入你认为的数字:'))
if z == sc:
    print('输入正确!')
else:
    while z != sc:
        z=int(input('输入错误,请继续输入:'))
        if z == sc:
            print('哈哈,输入正确!')

myid='445323198805050828'
age=2018-int(myid[6:10])
print("年龄:"+str(age))
if int(myid [-2])% 2== 0:
    sex ="girl"
else:
    sex ="boy"
print("性别:"+sex)
s=myid[:2]
print("所在省份编号:"+s)
a=myid[2:4]
print("所在市份编号:"+a)
b=myid[6:14]
print("出生年月:"+b)

s='201606050060'

b=s[0:4]
print("班级:"+b)
c=s[4:8]
print("专业:"+c)
d=s[-4:]
print("学号:"+d)
e=b+c
print("b连接c为:"+e)
g=b*3
print("g重复3次为:"+g)
h='b' in 'c'
print(h)

for i in range(10):
  print('http://news.gzcc.cn/html/xiaoyuanxinwen /'+str(i) + '.html')

s='dggwewgcsd'
for c in s:
    print("字母:"+c)

posted on 2018-09-13 13:15  刘燕君  阅读(100)  评论(0编辑  收藏  举报

导航