'''task1_1.py'''
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.py'''
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.py'''
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.py'''
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_1.py'''
from turtle import*
def square(size=50,rgb='orange'):
'''
:para:size:int
:para:c:str
'''
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()
'''task3_2.py'''
from turtle import *
setup(800,600)
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.py'''
from turtle import * setup(800,600) bgcolor('black') pencolor('white') speed(0) angle=0 size=2 n=4 count=50 for i in range(count): fd(size) angle+=360/n+1 seth(angle) size+=5 hideturtle() done()
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/5 seth(angle) size+=5 hideturtle() done()
from turtle import * def move(x,y): penup() goto(x,y) pendown() def draw(n,a,size = 100): color(a) begin_fill() for i in range(n): fd(size) left(360/n) end_fill() move(-100,-100) draw(4,'black',200) move(-100,0) right(45) draw(4,'red',100*(2)**0.5) hideturtle() done()
from turtle import * pensize(2) def move(x,y): penup() goto(x,y) pendown() def quarter_round(r): pencolor('blue') move(0,r) circle(-r,90) for i in range(2): right(90) fd(r) home() radius=40 offset=20 for i in range(5): quarter_round(radius) radius+=offset hideturtle() done()
from turtle import * def move(x,y): penup() goto(x,y) pendown() bgcolor('black') color('yellow') move(0,-100) begin_fill() circle(100) end_fill() color('black') speed(0) move(87,-51) seth(60) begin_fill() circle(100,80) home() end_fill() move(-30,60) dot(30,'black') move(-38,60) dot(5,'white') hideturtle() done()
标签:turtle,python,move,range,绘图,import,def,size From: https://www.cnblogs.com/cxb17/p/17458447.html