import turtle turtle.shape(‘turtle‘) turtle.speed(5) turtle.color(‘green‘) var=1 while var == 1: for i in range(5): turtle.forward(200) turtle.right(144)
无限循环的五角星
from turtle import* for i in range(5): up() goto(0,-20*i) down() circle(20*i)
用循环画同心圆
import turtle turtle.shape(‘turtle‘) turtle.speed(5) turtle.color(‘yellow‘) turtle.bgcolor(‘red‘) turtle.fillcolor(‘yellow‘) def my_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() def my_star5(r): turtle.begin_fill() for i in range(5): turtle.forward(r) turtle.right(144) turtle.end_fill() my_goto(-250,100) my_star5(100) my_goto(-150,75) my_star5(50) my_goto(-100,50) my_star5(50) my_goto(-50,25) my_star5(50) my_goto(-0,0) my_star5(50)
用函数画了五个五角星
import turtle def draw_diamond(brad): brad.forward(100) brad.right(45) brad.forward(100) brad.right(135) def draw_art(): window=turtle.Screen() window.bgcolor("pink") brad=turtle.Turtle() brad.shape(‘turtle‘) brad.color(‘yellow‘) brad.speed(100) for i in range(1,37): draw_diamond(brad) draw_diamond(brad) brad.left(10) draw_art()
画一朵花
r = input("请输入学号:") print("学年:",r[:4]) print(r[4:6],":代表网络工程") print("学号:",r[10:12])
输入学号识别年级专业序号
r = input("请输入数字:") print(‘星期‘,r)
星期几
时间: 2024-10-27 23:26:19