
请问这个第二问python用for循环怎么画五环,希望可以有完整代码
2401_83458979 上午好☀️☀️☀️️
本答案参考ChatGPT-3.5
以下是使用for循环绘制五环的Python代码:
import turtle
def draw_circle(x, y, color):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.color(color)
turtle.circle(45)
colors = ['blue', 'black', 'red', 'yellow', 'green']
positions = [(-110, -25), (0, -25), (110, -25), (-55, -75), (55, -75)]
turtle.pensize(10)
for position, color in zip(positions, colors):
draw_circle(position[0], position[1], color)
turtle.done()
代码解析:
希望以上代码和解释对你有帮助!