条件循环函数定义字符串操作练习
Posted 201406114436唐盛阳
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了条件循环函数定义字符串操作练习相关的知识,希望对你有一定的参考价值。
import turtle for i in range(5): turtle.forward(200) turtle.left(144)
1 import turtle 2 turtle.color(\'green\') 3 for i in range(4): 4 turtle.up() 5 turtle.goto(0,-40*(i+1)) 6 turtle.down() 7 turtle.circle(40*(i+1))
1 from turtle import* 2 color(\'red\',\'yellow\') 3 begin_fill() 4 while True: 5 forward(200) 6 left(170) 7 if abs(pos())<1: 8 break 9 end_fill() 10 done()
1 import turtle 2 turtle.bgcolor(\'red\') 3 turtle.color(\'yellow\') 4 turtle.fillcolor(\'yellow\') 5 6 def guo_goto(x,y): #定义位置 7 turtle.up() 8 turtle.goto(x,y) 9 turtle.down() 10 11 def guo_draw(x): #画星星 12 turtle.begin_fill() 13 for i in range(5): 14 turtle.forward(x) 15 turtle.right(144) 16 turtle.end_fill() 17 18 guo_goto(-300,200) #大星星 19 guo_draw(170) 20 21 22 guo_goto(30,280) 23 guo_draw(60) 24 25 guo_goto(120,200) 26 guo_draw(60) 27 28 guo_goto(120,126) 29 guo_draw(60) 30 31 guo_goto(30,60) 32 guo_draw(60)
1 import turtle 2 turtle.color(\'green\') 3 while True: 4 turtle.forward(100) 5 turtle.left(50) 6 turtle.forward(200) 7 turtle.left(130) 8 turtle.forward(100) 9 turtle.left(50) 10 turtle.forward(210) 11 turtle.right(20) 12 if abs(turtle.pos())<1: 13 break 14 turtle.done()
name = input("请输入名字:")
num = input("请输入学号:")
print("{}同学您好。".format(name))
print("您的年级为:{}级".format(num[0:4]))
if(int(num[8:10])==43):
print("您的班级为:网络工程1班")
elif(int(num[8:10])==44):
print("您的班级为:网络工程2班")
elif(int(num[8:10])==41):
print("您的班级为:软件工程1班")
elif(int(num[8:10])==42):
print("您的班级为:软件工程2班")
print("您的序号为:{}".format(num[-2:]))
1 a=input(\'今天是星期几?\') 2 if a==\'1\': 3 print(\'星期一\') 4 elif a==\'2\': 5 print(\'星期二\') 6 elif a==\'3\': 7 print(\'星期三\') 8 elif a==\'4\': 9 print(\'星期四\') 10 elif a==\'5\': 11 print(\'星期五\') 12 elif a==\'6\': 13 print(\'星期六\') 14 else: 15 print(\'星期日\')
ID=input(\'请输入您的身份证号码:\') P=[\'广东省\',\'四川省\'] C=[\'广州市\',\'深圳市\',\'成都市\'] R=[\'越秀区\',\'白云区\',\'天河区\',\'福田区\',\'南山区\',\'罗湖区\'] p=int(ID[0:2]) c=int(ID[2:4]) r=int(ID[4:6]) sex=int(ID[16]) age=int(ID[6:10]) if p==44: print("您所属的省:",P[0]) elif p==51: print("您所属的省:",P[1]) else: print(\'查无数据。\') if p==44: if c==1: print(C[0]) if r==4: print(D[0]) elif r==11: print(D[1]) elif r==6: print(D[2]) else: print(\'无数据。\') elif c==3: if r==4: print(D[3]) elif r==5: print(D[4]) elif r==3: print(D[5]) else: print(\'无数据。\') else: print(\'无数据。\') if p==51: if c==1 and r==8: print(C[2],R[6]) else: print(\'无数据。\') if sex%2==0: print(\'女性\') else: print(\'男性\') age=2017-int(age) print(\'您今年{}岁\'.format(age))
以上是关于条件循环函数定义字符串操作练习的主要内容,如果未能解决你的问题,请参考以下文章