这是我的代码,但是我很困惑如何访问color数组和坐标x&y数组,以便可以通过所有索引访问它。在
from turtle import *
setup()
title('4 CIRCLES')
col = ['yellow', 'green', 'blue', 'red']
x = [100,65,30,5]
y = [100,65,30,5]
def lingkaran(number, rad = 50) :
for cir in range(number) :
penup()
goto(x, y)
pendown()
color(col)
begin_fill()
circle(rad)
end_fill()
lingkaran(4)
hideturtle()
done()
我想通过访问数组来简化它,希望有人能帮忙。 谢谢
因为我们观察的是一个固定的圆之间的距离,所以我会用坐标数组来代替起始位置和偏移量。然后我只在颜色数组上循环:
但对于这样的问题,有很多方法可以解决。在
相关问题 更多 >
编程相关推荐