Python turtle点状图(2.0)
from turtle import *
import random
#子程序
#多边形def
def dbx(bs,bc):
a=random.randint(0,255)
b=random.randint(0,255)
c=random.randint(0,255)
colormode(255)
pencolor((a,b,c))
fillcolor((a,b,c))
begin_fill()
circle(bc/2)
end_fill()
#每一行的输出
def hang():
for i in range(10):
dbx(3,20)
up()
fd(30)
pd()
#每一列的输出
def lie():
for i in range(9):
up()
rt(90)
fd(30)
rt(90)
fd(300)
rt(180)
hang()
#主程序
speed(0)
#定位
pu()
fd(-150)
lt(90)
fd(150)
rt(90)
pd()
hang()
lie()
hideturtle()

2.0版本新增加了定位
turtle画笔默认原来位置是在正中
定位功能在主程序部分将画笔移到左上角使图像出现在中央
附:在IDLE中运行时注意对齐