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))
![](https://images2018.cnblogs.com/blog/1482883/201809/1482883-20180913130256071-727138447.png)
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('哈哈,输入正确!')
![](https://images2018.cnblogs.com/blog/1482883/201809/1482883-20180913130735478-268819419.png)
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)
![](https://images2018.cnblogs.com/blog/1482883/201809/1482883-20180913130936353-438545349.png)
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)
![](https://images2018.cnblogs.com/blog/1482883/201809/1482883-20180913131112737-1289766338.png)
for i in range(10):
print('http://news.gzcc.cn/html/xiaoyuanxinwen /'+str(i) + '.html')
![](https://images2018.cnblogs.com/blog/1482883/201809/1482883-20180913131239040-1365950130.png)
s='dggwewgcsd'
for c in s:
print("字母:"+c)
![](https://images2018.cnblogs.com/blog/1482883/201809/1482883-20180913131335293-2107137629.png)