task1
1 from turtle import * 2 def move(x, y): 3 penup() 4 goto(x, y) 5 pendown() 6 def draw(n, size = 100): 7 for i in range(n): 8 fd(size) 9 left(360/n) 10 def main(): 11 pensize(2) 12 pencolor('red') 13 move(-200, 0) 14 draw(3) 15 move(0, 0) 16 draw(4) 17 move(200, 0) 18 draw(5) 19 hideturtle() 20 done() 21 main()
task2
1 from turtle import * 2 def moveto(x, y): 3 penup() 4 goto(x, y) 5 pendown() 6 def main(): 7 pensize(2) 8 pencolor('blue') 9 moveto(-150, 0) 10 circle(50) 11 moveto(0, 0) 12 circle(50, steps = 4) 13 moveto(150, 0) 14 circle(50, steps = 5) 15 moveto(300, 0) 16 circle(50, steps = 6) 17 hideturtle() 18 done() 19 main()
实验任务2
task1
1 from turtle import * 2 def moveto(x, y): 3 penup() 4 goto(x, y) 5 pendown() 6 def main(): 7 setup(800, 600) 8 radius = 20 9 offset = 20 10 for i in range(9): 11 moveto(0, -radius) 12 circle(radius) 13 radius += offset 14 hideturtle() 15 done() 16 main()
task2
1 from turtle import * 2 from random import random 3 def moveto(x, y): 4 penup() 5 goto(x, y) 6 pendown() 7 def gen_color(): 8 return tuple((random() for i in range(3))) 9 def main(): 10 setup(800, 600) 11 radius = 180 12 offset = 20 13 for i in range(8): 14 moveto(0, -radius) 15 color(gen_color()) 16 begin_fill() 17 circle(radius) 18 end_fill() 19 radius -= offset 20 hideturtle() 21 done() 22 main()
实验任务3
task1
1 from turtle import * 2 def square(size = 50, rgb = 'orange'): 3 pencolor(rgb) 4 for i in range(4): 5 fd(size) 6 left(90) 7 def main(): 8 setup(800, 600) 9 speed(0) 10 n = 10 11 for i in range(n): 12 square(80) 13 left(360/n) 14 hideturtle() 15 done() 16 main()
task2
1 from turtle import * 2 setup(800, 600) 3 pencolor('pink') 4 n = 10 5 for i in range(10): 6 # 绘制一片花瓣 7 for j in range(2): 8 circle(80, 90) 9 left(90) 10 right(360/n) 11 hideturtle() 12 done()
1 from turtle import * 2 setup(800, 600) 3 bgcolor('black') 4 pencolor('white') 5 speed(0) 6 angle = 0 7 size = 2 8 n = 5 9 count = 50 10 for i in range(count): 11 fd(size) 12 angle += 360/n 13 seth(angle) 14 size += 5 15 hideturtle() 16 done()
1 from turtle import * 2 def moveto(x, y): 3 penup() 4 goto(x, y) 5 pendown() 6 7 def main(): 8 moveto(-100,-100) 9 color('black') 10 begin_fill() 11 for i in range(4): 12 forward(200) 13 left(90) 14 end_fill() 15 color('red') 16 begin_fill() 17 moveto(0,-100) 18 circle(100,steps=4) 19 end_fill() 20 main()
1 from turtle import * 2 def moveto(x, y): 3 penup() 4 goto(x, y) 5 pendown() 6 7 def main(): 8 pencolor('blue') 9 pensize(2) 10 n=40 11 for i in range(5): 12 moveto(0,0) 13 forward(n) 14 left(90) 15 circle(n,90) 16 left(90) 17 forward(n) 18 left(90) 19 n+=20 20 21 main()
1 from turtle import * 2 def moveto(x, y): 3 penup() 4 goto(x, y) 5 pendown() 6 7 def main(): 8 bgcolor('black') 9 color('yellow') 10 begin_fill() 11 moveto(0,0) 12 left(45) 13 forward(100) 14 left(90) 15 circle(100,270) 16 left(90) 17 forward(100) 18 end_fill() 19 moveto(15,60) 20 color('black') 21 begin_fill() 22 circle(10,360) 23 end_fill() 24 moveto(5,55) 25 color('white') 26 begin_fill() 27 circle(2,360) 28 end_fill() 29 hideturtle() 30 main()
标签:10,moveto,实验,circle,main,def,fill From: https://www.cnblogs.com/simple77/p/17466545.html