标签:while循环 .com pos 字符串 rtl orm 软件 and war
用循环画五角星
>>> import turtle >>> for i in range(5): turtle.forward(100) turtle.right(144)
用循环画同心圆
>>> import turtle >>> for i in range(4): turtle.penup() turtle.goto(0,-40*i) turtle.pendown() turtle.circle(40*i)
用while循环画太阳花
>>> from turtle import* >>> color(‘red‘,‘blue‘) >>> begin_fill() >>> while True: forward(200) left(170) if (abs(pos()))<1: break >>> end_fill() >>> done()
用函数定义画五个五角星
>>>import turtle >>>turtle.setup(600,400) >>>turtle.color("yellow") >>>turtle.bgcolor("red") >>>turtle.fillcolor("yellow") >>>turtle.speed(10) >>>def turtle_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() >>>def darw_star(d): turtle.begin_fill() for i in range(5): turtle.forward(d) turtle.right(144) turtle.end_fill() >>>turtle_goto(-260,120) >>>darw_star(120) >>>turtle_goto(-110,160) >>>turtle.left(40) >>>darw_star(40) >>>turtle_goto(-65,125) >>>turtle.right(10) >>>darw_star(40) >>>turtle_goto(-55,55) >>>turtle.left(40) >>>darw_star(40) >>>turtle_goto(-110,15) >>>turtle.right(20) >>>darw_star(40)
用函数定义画钻石花瓣的太阳花
>>>import turtle >>>turtle.speed(30) >>>turtle.color("green") >>>turtle.fillcolor("blue") >>>def draw_rhombus(size): for i in range(2): turtle.fd(size) turtle.left(20) turtle.fd(size) turtle.left(160) >>>turtle.right(90) >>>turtle.begin_fill() >>>for i in range(36): draw_rhombus(100) turtle.left(10) >>>turtle.end_fill() >>>turtle.fd(400)
输入学号,识别年级、专业、序号
>>>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-7的数字,输出对应的“星期几”
>>>s="星期一星期二星期三星期四星期五星期六星期天" >>>a=int(input("请输入(1-7):")) >>>if(0<a<8): print(s[-3+3*a:0+3*a]) >>>else: 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))
标签:while循环 .com pos 字符串 rtl orm 软件 and war
原文地址:http://www.cnblogs.com/yingja-hong/p/7518861.html