第一版:
import turtle
import random
color=''
width=x=y=0
t=turtle.Turtle()
t.hideturtle()
t.speed(0)
t.penup()
for i in range(random.randint(500,1000)):
t.penup()
width=random.randint(1,100)
x=random.uniform(-205.00,205.00)
y=random.uniform(-205.00,205.00)
color='#'+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])
t.pensize(width)
t.color(color)
t.goto(x,y)
t.pendown()
t.goto(x-0.01,y)
turtle.done()
第一版的运行效果:
随机点彩画-胡浩宇-侯老师编程网站(codinghou.cn) - Scratch编程教程与创作社区随机点彩画-胡浩宇 ;侯老师编程网站,既有高质量的免费教程,也有更精品的系统课程,涵盖我的世界、植物大战僵尸、塔防、卡牌、象棋等热门游戏制作教程,以及教师节、母亲节、中秋节等创意动画制作教程,更有单词、成语、音乐、数学、排座位等学习工具制作教程,还可以免费下载ScratchPythonVSCode等常见编程软件,话不多说,开始编程,一起体验思考的乐趣!
https://www.codinghou.cn/work/workdetail/153804
第二版:
import turtle
import random
color=''
width=x=y=0
t=turtle.Turtle()
t.hideturtle()
t.speed(0)
t.penup()
for i in range(random.randint(514,1145)):
t.penup()
width=random.randint(1,500)
x=random.uniform(-1000,1000)
y=random.uniform(-1000,1000)
color='#'+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])+random.choice(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])
t.pensize(width)
t.color(color)
t.goto(x,y)
t.pendown()
t.goto(x-0.01,y)
turtle.done()
第二版的运行效果(见这些示例):


