实验任务1
task1-1
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()View Code
task1-2
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()View Code
实验任务2
task2-1
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()View Code
task2-2
1 from turtle import * 2 from random import random 3 4 def moveto(x,y): 5 penup() 6 goto(x,y) 7 pendown 8 9 def gen_color(): 10 return tuple((random() for i in range(3))) 11 12 def main(): 13 setup(800,600) 14 15 radius = 180 16 offset = 20 17 18 for i in range(8): 19 moveto(0,-radius) 20 color(gen_color()) 21 22 begin_fill() 23 circle(radius) 24 end_fill() 25 26 radius -= offset 27 28 hideturtle() 29 done() 30 31 main()View Code
实验任务3
task3-1
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()View Code
task3-2
1 from turtle import * 2 speed(0) 3 setup(800, 600) 4 pencolor('pink') 5 n = 10 6 for i in range(n): 7 for j in range(2): 8 circle(80, 90) 9 left(90) 10 right(360/n) 11 hideturtle() 12 done()View Code
实验任务4
1 from turtle import * 2 setup(800, 600) 3 bgcolor('black') 4 pencolor('white') 5 speed(0) 6 7 angle = 0 8 size = 2 9 10 n = 5 #改 11 count = 50 12 for i in range(count): 13 fd(size) 14 angle += 360/n #改 15 seth(angle) 16 size += 5 17 18 hideturtle() 19 done()View Code
实验任务5
task5-1
1 #5 2 from turtle import * 3 4 penup() 5 goto(-100,-100) 6 pendown() 7 color('black') 8 begin_fill() 9 for i in range(4): 10 forward(200) 11 left(90) 12 end_fill() 13 14 penup() 15 goto(0,-100) 16 pendown() 17 left(45) 18 color('red') 19 begin_fill() 20 for i in range(4): 21 forward(100*2**(0.5)) 22 left(90) 23 end_fill() 24 25 hideturtle() 26 done()View Code
task5-2
1 from turtle import * 2 color('blue') 3 r = 20 4 for i in range(5): 5 r += 20 6 forward(r) 7 left(90) 8 circle(r,90) 9 left(90) 10 forward(r) 11 left(90) 12 forward(40) 13 goto(0,0) 14 hideturtle() 15 done()View Code
实验任务6
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()View Code
标签:turtle,10,moveto,python,绘图,main,def,left From: https://www.cnblogs.com/202280060019x/p/17474206.html