Python 第8章课后练习2 以原点为中心,绘http制5个同心圆,半径分别为20,40,60,80,100,填充的颜色依次使用Purple,Green,Gold,Red,Blue。

Python 第8章课后练习2 以原点为中心,绘制5个同心圆,半径分别为20,40,60,80,100,填充的颜色依次使用Purple,Green,Gold,Red,Blue,如图8-24所示。

代码如下:

import turtle
c=['Purple','Green','Gold','Red','Blue']
n=0
turtle.ht()
for i in range(6):
    turtle.fillcolor(c[n])
    n=n+1
    turtle.begin_fill()
    turtle.circle(100-i*20)  
    turtle.end_fill()
    turtle.penup()
    turtle.goto(0,0+(i+1)*20)
    turtle.pendown()

运行结果:
Python 第8章课后练习2 以原点为中心,绘http制5个同心圆,半径分别为20,40,60,80,100,填充的颜色依次使用Purple,Green,Gold,Red,Blue。_第1张图片

你可能感兴趣的:(Python课后练习,几何学,pycharm,ide,python)