标签:idc 函数名 吉林省 card 字典 ddl span got 专业
要求:
作答:
1用循环画五角星
turtle.begin_fill() for i in range(5): turtle.forward(100) turtle.right(144) turtle.end_fill
2用循环画同心圆
from turtle import* for i in range(5): up() goto(0,-20*i) down() circle(20*i)
3用while循环画太阳花
复制代码 color(‘red‘,‘yellow‘) begin_fill() while True: forward(200) left(170) if abs(pos())<1: break end_fill() don
4用函数定义画五个五角星
import turtle turtle.setup(600,400,0,0) turtle.color("yellow") turtle.bgcolor("red") turtle.fillcolor("yellow") def yyj_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() def yyj_draw(r): turtle.begin_fill() for i in range(5): turtle.forward(r) turtle.right(144) turtle.end_fill() yyj_goto(-600,220) yyj_draw(150) yyj_goto(-400,295) yyj_draw(50) yyj_goto(-350,212) yyj_draw(30) yyj_goto(-350,145) yyj_draw(30) yyj_goto(-400,90) yyj_draw(30)
5用函数定义画钻石花瓣的太阳花
from turtle import * 2 def draw_lx(): 3 for i in range(1,3): 4 forward(100) 5 right(45) 6 forward(100) 7 right(135) 8 9 def draw_zsh(): 10 speed(10) 11 color(‘red‘,‘yellow‘) 12 begin_fill() 13 for i in range(36): 14 draw_lx() 15 right(10) 16 end_fill() 17 18 draw_zsh()
字符串操作
def shibie(studentID): 2 if len(studentID)<12: 3 print("请输入正确的学号!") 4 elif studentID.isdigit() != True: 5 print("请输入正确的学号!") 6 else: 7 grade = studentID[0:4] 8 profession = studentID[4:8] 9 order = studentID[10:12] 10 print("年级:{}级".format(grade)) 11 if profession == "0611": 12 print("专业:网络工程") 13 print("序号:{}".format(order)) 14 15 studentID = input("请输入学号:") 16 shibie(studentID)
def xq(xqj): 2 xqj = int(xqj) 3 if 0<xqj<8: 4 str = "星期一星期二星期三星期四星期五星期六星期日" 5 xq = str[(xqj-1)*3:(xqj-1)*3+3] 6 print("{} 是 {}".format(xqj,xq)) 7 else: 8 print("请输入正确数字!") 9 10 xqj = input("输入1-7的数字:") 11 xq(xqj)
import time 2 3 #省份对应字典 4 provinces = { 5 11:‘北京市‘, 6 12:‘天津市‘, 7 13:‘河北省‘, 8 14:‘山西省‘, 9 15:‘内蒙古自治区‘, 10 21:‘辽宁省‘, 11 22:‘吉林省‘, 12 23:‘黑龙江省‘, 13 31:‘上海市‘, 14 32:‘江苏省‘, 15 33:‘浙江省‘, 16 34:‘安徽省‘, 17 35:‘福建省‘, 18 36:‘江西省‘, 19 37:‘山东省‘, 20 41:‘河南省‘, 21 42:‘湖北省‘, 22 43:‘湖南省‘, 23 44:‘广东省‘, 24 45:‘广西壮族自治区‘, 25 46:‘海南省‘, 26 50:‘重庆市‘, 27 51:‘四川省‘, 28 52:‘贵州省‘, 29 53:‘云南省‘, 30 54:‘西藏自治区‘, 31 61:‘陕西省‘, 32 62:‘甘肃省‘, 33 63:‘青海省‘, 34 64:‘宁夏回族自治区‘, 35 65:‘新疆维吾尔自治区‘, 36 71:‘台湾省‘, 37 81:‘香港特别行政区‘, 38 91:‘澳门特别行政区‘ 39 } 40 41 def shibie(IDcard): 42 province = IDcard[0:2] 43 birthYear = IDcard[6:10] 44 localYear = time.strftime(‘%Y‘) 45 age = int(localYear) - int(birthYear) 46 sex = IDcard[16:17] 47 print("省份为:",provinces.get(int(province))) 48 print("年龄为:{}".format(age)) 49 if int(sex) % 2 == 0: 50 print("性别:女") 51 else: 52 print("性别:男") 53 54 IDcard = input("请输入身份证:") 55 shibie(IDcard)
标签:idc 函数名 吉林省 card 字典 ddl span got 专业
原文地址:http://www.cnblogs.com/20chenguanglin/p/7517888.html