## 条件、循环、函数定义、字符串操作练习

2017-09-14 18:44  421徐均钧  阅读(203)  评论(0编辑  收藏  举报

import turtle
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()


from turtle import*

for i in range(5):
up()
goto(0,-20*i)
down()
circle(20*i)


from turtle import *
color('orange','yellow')
begin_fill()
while True:
forward(200)
left(170)
if(abs(pos()))<1:
break
end_fill()
done()


import turtle
turtle.setup(600,400,0,0)
turtle.color("yellow")
turtle.bgcolor('red')
turtle.fillcolor("yellow")

def xy(x,y):
turtle.up()
turtle.goto(x,y)
turtle.down()

def draw(r):
turtle.begin_fill()
for i in range(5):
turtle.forward(r)
turtle.right(144)
turtle.end_fill()

xy(-273,110)
draw(100)

xy(-121,162)
turtle.left(45)
draw(50)

xy(-79,110)
draw(50)

xy(-79,51)
turtle.right(45)
draw(50)

xy(-121,22)
turtle.right(45)
draw(50)


import turtle

def draw_art():
window=turtle.Screen()
window.bgcolor("pink")

for i in range(1,13):

window.exitonclick()

draw_art()


.输入学号，识别年级、专业、序号

professions = {
1144:'网络工程',
1143:'网络工程',
1142:'软件工程',
1141:'数字媒体',
}

def distinguish(studentID):
if len(studentID)<12:
print("请输入正确的学号！")
elif studentID.isdigit() != True:
print("请输入正确的学号！")
else:
profession = studentID[6:10]
num = studentID[10:12]
print("专业：",professions.get(int(profession)))
print("序号:  {}号".format(num))

studentID = input("请输入学号：")
distinguish(studentID)


s="星期一星期二星期三星期四星期五星期六星期天"
i=int(input("请输入(1-7)："))
if(0<i<8):
print(s[-3+3*i:0+3*i])
else:
print("输入有误!")


ID=input('请输入十八位身份证号码: ')
if len(ID)!=18:
print("错误的身份证号码!!")

ID_birth=ID[6:10]
ID_sex=ID[14:17]

print("省市区:广东省广州市市辖区")
print("省市区:广东省广州市东山区")
print("省市区:广东省广州市荔湾区")
print("省市区:广东省广州市越秀区")
print("省市区:广东省广州市海珠区")

birth=2017-int(ID_birth[0:4])
print("年龄：{}".format(birth))

if int(ID_sex)%2==0:
print('性别：女')
else:
print('性别：男')