欢迎光临散文网 会员登陆 & 注册

Python turtle点状图1.0(三角形)

2023-02-19 14:50 作者:宝贝是墨香  | 我要投稿

1.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()

    for i in range(bs):

        fd(bc)

        right(360/bs)

    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)

hang()

lie()

hideturtle()

1.0(三角形版本)


Python turtle点状图1.0(三角形)的评论 (共 条)

分享到微博请遵守国家法律