task1-1
from turtle import * def move(x, y): penup() goto(x, y) pendown() def draw(n, size = 100): for i in range(n): fd(size) left(360/n) def main(): pensize(2) pencolor('red') move(-200,0) draw(3) move(0, 0) draw(4) move(200, 0) draw(5) hideturtle() done() main()
截图
task1-2
from turtle import * def moveto(x, y): penup() goto(x, y) pendown() def main(): pensize(2) pencolor('blue') moveto(-150, 0) circle(50) moveto(0, 0) circle(50, steps = 4) moveto(150, 0) circle(50, steps = 5) moveto(300, 0) circle(50, steps = 6) hideturtle() done() main()
截图
task2-1
from turtle import * def moveto(x, y): penup() goto(x, y) pendown() def main(): setup(800, 600) radius = 20 offset = 20 for i in range(9): moveto(0, -radius) circle(radius) radius += offset hideturtle() done() main()
截图
task2-2
from turtle import * from random import random def moveto(x, y): penup() goto(x, y) pendown() def gen_color(): return tuple((random() for i in range(3))) def main(): setup(800, 600) radius = 180 offset = 20 for i in range(8): moveto(0, -radius) color(gen_color()) begin_fill() circle(radius) end_fill() radius -= offset hideturtle() done() main()
截图
task3
from turtle import * def square(size = 50, rgb = 'orange'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800, 600) speed(0) n = 11 for i in range(n): square(80) left(360/n) hideturtle() done() main()
截图
task3-2
from turtle import * setup(800, 500) pencolor('pink') n = 10 for i in range(10): for j in range(2): circle(80, 90) left(90) right(360/n) hideturtle() done()
截图
task4
from turtle import * setup(800, 600) bgcolor('black') pencolor('white') speed(0) angle = 0 size = 2 n = 5 count = 50 for i in range(count): fd(size) angle += 360/n seth(angle) size += 5 hideturtle() done()
截图
task5-1
from turtle import * def moveto(x, y): penup() goto(x, y) pendown() pensize(3) color('black') begin_fill() moveto(-100, -100) for i in range(4): fd(200) left(360/4) end_fill() moveto(0, -100) color('red') begin_fill() circle(100,steps = 4) end_fill() hideturtle() done()
截图
task5-2
from turtle import * pensize(2) pencolor('blue') r = 40 for i in range(5): fd(r) left(90) circle(r,90) left(90) fd(r) left(90) r += 20 hideturtle() done()
截图
task6
moveto(200,-200) color('yellow') begin_fill() left(135) fd(200) right(90) fd(200) left(90) circle(200,270) end_fill() moveto(80,70) dot(40,'black') moveto(72,76) dot(10,'white') hideturtle() done()
截图
标签:moveto,hideturtle,range,done,import,实验,def From: https://www.cnblogs.com/melancholy-z/p/17475020.html