实验任务1-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()
运行测试截图
实验任务1-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()
运行测试截图
实验任务2-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()
运行测试截图
实验任务2-2
实验源码
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-1
实验源码
from turtle import * def square(size = 50, rgb = 'yellow'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800,600) speed(0) n = 10 for i in range(n): square(80) left(360/n) hideturtle() done() main()
运行测试截图
实验任务3-2
实验源码
1 from turtle import * 2 setup(800,600) 3 pencolor('pink') 4 5 n = 10 6 for i in range(n): 7 for j in range(2): 8 circle(80,90) 9 left(90) 10 11 right(360/n) 12 13 hideturtle() 14 done()
运行测试截图
实验任务4
实验源码
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()
运行测试截图
实验任务5-1
实验源码
1 from turtle import * 2 penup() 3 goto(-100,-100) 4 pendown() 5 color('black') 6 begin_fill() 7 for i in range(4): 8 fd(200) 9 left(90) 10 end_fill() 11 penup() 12 goto(-100,0) 13 pendown() 14 seth(45) 15 color('red') 16 begin_fill() 17 for i in range(4): 18 fd(100*(2**0.5)) 19 right(90) 20 end_fill() 21 done()
运行测试截图
实验任务5-2
实验源码
1 from turtle import * 2 3 def moveto(x,y): 4 penup() 5 goto(x,y) 6 pendown() 7 moveto(0,0) 8 pensize(2) 9 pencolor('blue') 10 11 def main(): 12 radius = 40 13 offset = 20 14 for i in range(5): 15 fd(radius) 16 left(90) 17 circle(radius, 90) 18 left(90) 19 fd(radius) 20 moveto(0,0) 21 seth(0) 22 radius+=offset 23 done() 24 main()
运行测试截图
实验任务6
实验源码
1 from turtle import * 2 def move(x,y): 3 penup() 4 goto(x,y) 5 pendown() 6 bgcolor('black') 7 color('yellow') 8 move(0,-100) 9 begin_fill() 10 circle(100) 11 end_fill() 12 color('black') 13 speed(0) 14 move(87,-51) 15 seth(60) 16 begin_fill() 17 circle(100,80) 18 home() 19 end_fill() 20 move(-30,60) 21 dot(30,'black') 22 move(-38,60) 23 dot(5,'white') 24 25 hideturtle() 26 done()
运行测试截图
标签:moveto,range,radius,实验,main,def From: https://www.cnblogs.com/yongzhulazhen/p/17458351.html