# 重复执行有次数限定 无限循环
# for 循环
# 格式
# color颜色
# 三原色 红黄蓝 颜料
# 三基色 光 0-1 颜色深度 红 绿 蓝
# 0-1 0-255
"""
for 变量名 in 集合:
执行语句
"""
import turtle
import random
turtle.speed(0)
for i in range(9999):
for b in range(5):
turtle.fd(100)
turtle.lt(144)
# 红 绿 蓝 i的数值范围
a = random.random()
p = random.random()
o = random.random()
turtle.fd(10)
turtle.rt(100)
turtle.color(a, o, p)
```
song -这节课我们主要学习了for循环和颜色
最新推荐文章于 2026-06-05 08:57:30 发布
本博客介绍了一个使用Python的Turtle模块进行无限循环绘图的例子,并展示了如何通过随机生成红、绿、蓝三种颜色的深度来实现颜色渐变效果。代码中运用了for循环结构和随机数生成函数,使每次运行都能得到独特的视觉效果。

7860

被折叠的 条评论
为什么被折叠?



