#温度转换
while True:
a=int(input ("华氏转摄氏请按1\n摄氏转华氏请按2\n"))
if a==1:
h1=float(input ("请输入一个华氏温度:"))
s1= 5/9 *(h1-32)
print ("摄氏温度为\n",format(s1))
elif a==2:
h2 = float(input("请输入一个摄氏温度:"))
s2 =h2*9/5+32
print("华氏温度为\n", format(s2))
else:
break
![](https://img2018.cnblogs.com/blog/1482909/201809/1482909-20180913211432481-317346114.png)
#解析身份证号、学号不同片段的含义
myid='440121199705094322'
age=2018-int(myid[6:10])
if int(myid[-2])%2==0:
sex='girl'
else:
sex='boy'
print(age,sex)
if myid[0:4] =="4401":
area = "广东省广州市"
year = myid[6:10]
month = myid[10:12]
date = myid[12:14]
print("我来自"+area+",是一名"+sex+",出生年月日是:"+year+month+date)
![](https://img2018.cnblogs.com/blog/1482909/201809/1482909-20180913211715931-615178084.png)
#用字符串表示自己的学号,分隔出年级、专业、班级、序号
s ='201606050054'
a=s[:4]
b=s[4:6]
c=s[6:8]
d=s[8:]
if s[4:6]=="06":
area="信息技术与工程学院"
print('年级{}'.format(a))
print('学院{}'.format(area))
print('班级{}'.format(c))
print('学号{}'.format(d))
![](https://img2018.cnblogs.com/blog/1482909/201809/1482909-20180913211933272-1899724643.png)
#字符串的:连接,重复,in判断
a='girl'
b='5'
print(a+b)
print(a*3)
print('girl'in a+b)
![](https://img2018.cnblogs.com/blog/1482909/201809/1482909-20180913212103306-1051075203.png)
#猜数字游戏
number=10
while True:
n1=int(input("请输入你要猜的数字:"))
if n1>number:
print("你猜的数字太大了")
elif n1<number:
print("你猜的数字太小了")
else:
print("你猜对了")
break
![](https://img2018.cnblogs.com/blog/1482909/201809/1482909-20180913213343283-1812403849.png)
#用for循环产生一系列网址
for i in range(2,10):
print("http://news.gzcc.cn/html/2018/xiaoyuanxinwen/{}.html".format(i));
#用for循环产生一系列网址
for i in range(2,10):
print("http://news.gzcc.cn/html/2018/xiaoyuanxinwen/{}.html".format(i));
![](https://img2018.cnblogs.com/blog/1482909/201809/1482909-20180913213522901-108825384.png)