884
說明:
|
157
|
這個顏色代表刪除的 | 這個顏色代表增加的 |
行號 1: | 行號 1: |
import turtle import random |
from turtle import* |
行號 4: | 行號 3: |
def drawCircle(myTurtle, x,y, radius, color): myTurtle.penup() myTurtle.goto(x,y) myTurtle.pendown() myTurtle.begin_fill() myTurtle.color(color) myTurtle.circle(radius) myTurtle.end_fill() colors = ['red','yellow', 'blue', 'green', 'black', 'gray', 'pink'] radii = [10,20,30,40,50,60] numCircles = int(input('Enter number of circles:')) width = 500 height = 500 width2 = width//2 height2 = height//2 screen = turtle.Screen() screen.setup(width,height) myTurtle = turtle.Turtle() myTurtle.speed(0) for i in range(numCircles): x = random.randint(-width2,width2) y = random.randint(-height2,height2) radius = radii[random.randrange(0,len(radii))] color = colors[random.randrange(0,len(colors))] drawCircle(myTurtle,x,y,radius,color) screen.exitonclick() |
def square(x): for i in range(4): forward(x) left(90) x=x+20 for j in range(4): square(60) left(90) done() |
from turtle import*
def square(x):
- for i in range(4):
- forward(x) left(90) x=x+20
for j in range(4):
- square(60) left(90)
done()