标签:local orm imp 重庆市 .com 9.png day python 江苏省
一.循环画五角星
from turtle import * fillcolor("yellow") begin_fill() for i in range(5): forward(100) right(144) end_fill()
二.循环画同心圆
from turtle import * for i in range(5): up() goto(0,-48*i) down() circle(48*i) done()
三.循环画太阳花
from turtle import * color(‘red‘,‘yellow‘) begin_fill() while True: forward(250) left(177) if abs(pos())<1: break end_fill() done()
四.循环画五星红旗
import turtle turtle.setup(600,400,0,0) turtle.bgcolor("red") turtle.color("yellow") turtle.fillcolor("yellow") def zxq_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() def zxq_draw(x): turtle.begin_fill() for i in range(5): turtle.forward(x) turtle.right(144) turtle.end_fill() zxq_goto(-600,220) zxq_draw(150) zxq_goto(-400,295) zxq_draw(50) zxq_goto(-350,212) zxq_draw(30) zxq_goto(-350,145) zxq_draw(30) zxq_goto(-400,90) zxq_draw(30) done()
五.循环画钻石太阳花
import turtle turtle.color(‘red‘) while True: turtle.forward(100) turtle.left(50) turtle.forward(200) turtle.left(130) turtle.forward(100) turtle.left(50) turtle.forward(210) turtle.right(20) if abs(turtle.pos())<1: break turtle.done()
六.输入学号,识别年级,专业,序号
a=input("输入你的学号:") print(a[:]) if len(a)>12: print("输入错误!") print("年级:"+a[0:4]) print("专业:"+a[4:8]) print("序号:"+a[8:12])
七.输入1-7,输出对应的星期
a=input(‘今天是星期几?‘) if a==‘1‘: print(‘星期一‘) elif a==‘2‘: print(‘星期二‘) elif a==‘3‘: print(‘星期三‘) elif a==‘4‘: print(‘星期四‘) elif a==‘5‘: print(‘星期五‘) elif a==‘6‘: print(‘星期六‘) else: print(‘星期日‘)
八.识别身份证号中的省市区,年龄,性别
import time provinces = { 11:‘北京市‘, 12:‘天津市‘, 13:‘河北省‘, 14:‘山西省‘, 15:‘内蒙古自治区‘, 21:‘辽宁省‘, 22:‘吉林省‘, 23:‘黑龙江省‘, 31:‘上海市‘, 32:‘江苏省‘, 33:‘浙江省‘, 34:‘安徽省‘, 35:‘福建省‘, 36:‘江西省‘, 37:‘山东省‘, 41:‘河南省‘, 42:‘湖北省‘, 43:‘湖南省‘, 44:‘广东省‘, 45:‘广西壮族自治区‘, 46:‘海南省‘, 50:‘重庆市‘, 51:‘四川省‘, 52:‘贵州省‘, 53:‘云南省‘, 54:‘西藏自治区‘, 61:‘陕西省‘, 62:‘甘肃省‘, 63:‘青海省‘, 64:‘宁夏回族自治区‘, 65:‘新疆维吾尔自治区‘, 71:‘台湾省‘, 81:‘香港特别行政区‘, 91:‘澳门特别行政区‘ } def decide(cardID): province=cardID[0:2] birthdayYear=cardID[6:10] localYear=time.strftime(‘%Y‘) age=int(localYear)-int(birthdayYear) sex=cardID[16:17] print("省份为:", provinces.get(int(province))) print("年龄为:{}".format(age)) if int(sex)%2==0: print("性别:女") else: print("性别,男") cardID=input("请输入身份证号:") decide(cardID)
标签:local orm imp 重庆市 .com 9.png day python 江苏省
原文地址:http://www.cnblogs.com/zxq506911073/p/7518877.html