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

Posted 刘己铉

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了条件循环函数定义字符串操作练习相关的知识,希望对你有一定的参考价值。

from turtle import*
color("red")
fillcolor("red")
begin_fill()
while True:
    forward(200)
    right(144)
    if abs(pos())<1:
        break
end_fill()

import turtle
for i in range(3):
    turtle.up()
    turtle.goto(0,-20*(i+1))
    turtle.down()
    turtle.circle(20*(i+1))

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

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

def otherstart():
  turtle.begin_fill()
  for i in range(5):
    turtle.right(144)
    turtle.forward(35)
turtle.end_fill()
  
mygoto(-250,125)
mystar(125)

mygoto(-105,165)
turtle.left(40)
turtle.begin_fill()
for i in range(5):
    turtle.forward(35)
    turtle.right(144)
turtle.end_fill()

mygoto(-30,135)
turtle.right(10)
turtle.begin_fill()
for i in range(5):
    turtle.right(144)
    turtle.forward(35)
turtle.end_fill()

mygoto(-40,75)
turtle.left(40)
turtle.begin_fill()
for i in range(5):
    turtle.right(144)
    turtle.forward(35)
turtle.end_fill()

mygoto(-75,20)
turtle.right(20)
turtle.begin_fill()
for i in range(5):
    turtle.right(144)
    turtle.forward(35)
turtle.end_fill()

from turtle import *
def draw_prismatic():
    for i in range(1,3):  #要转三次方向来画一个菱形
        forward(100)
        right(45)
        forward(100)
        right(135)

def draw_Diamond_Flower():
    speed(10)
    color(\'red\',\'yellow\')
    begin_fill()
    for i in range(36):
        draw_prismatic()
        right(10)
    end_fill()

draw_Diamond_Flower()

majors = {
 11:\'网络工程\',
 12:\'软件工程\',
 13:\'数字媒体\',
 }

def recognition(studentID):
    if len(studentID)<12:
        print("请输入正确的学号!")
    elif studentID.isdigit() != True:
        print("请输入正确的学号!")
    else:
        grade = studentID[0:4]
        major = studentID[6:8]
        num = studentID[10:12]
        print("年级:{}级".format(grade))        
        print("专业为:",majors.get(int(major)))
        print("序号:{}".format(num))
        
studentID = input("请输入学号:")
recognition(studentID)

 

以上是关于条件循环函数定义字符串操作练习的主要内容,如果未能解决你的问题,请参考以下文章

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

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

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

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

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

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