Python简易代码画呼拉圈_颜色列表与求余练习

Python简易代码画呼拉圈_颜色列表与求余练习

"""
    画呼拉圈.py
     
"""
import turtle

colors = ['red','orange','yellow','green','cyan','blue','magenta']
amounts = len(colors)

screen = turtle.getscreen()    # 得到屏幕
screen.delay(0)                # 延时为0
screen.bgcolor('black')        # bgcolor 背景颜色
screen.title("Python简易代码画呼拉圈")

turtle.shape('turtle')
turtle.pensize(40)
turtle.goto(-100,100)         # 到坐标
 
for x in range(360):
    ys =  colors[x % amounts ]
    turtle.color(ys)
    turtle.fd(2)
    turtle.right(1)

 

李兴球

李兴球的博客是Python创意编程原创博客