大家好,我正在学习python3,但我被困在问题陈述中。修改花函数,使其允许使用不同数量的花瓣。修改后的功能将需要 附加参数:花(乌龟,fcolor,长度,花瓣) 注意原始功能有乌龟旅行 总共8 * 135 = 1080度。 当您概括花瓣数量时, 确保总度数仍然是360的倍数。
代码在下面。
`enter code here`
import turtle
def blossum(tortoise, fcolor, length, petals):
tortoise.pencolor('red')
tortoise.fillcolor(fcolor)
tortoise.begin_fill()
radius = 360
tortoise.circle(radius, steps)
tortoise.forward(length)
#for meh in range(8):
#tortoise.forward(length)
#tortoise.left(135)
tortoise.end_fill()
def stem(tortoise, length):
tortoise.pencolor('green')
tortoise.pensize(length / 20)
tortoise.up()
tortoise.forward(length / 2)
tortoise.down()
tortoise.right(90)
tortoise.forward(length)
def flower(tortoise, fcolor, length, petals):
blossum(tortoise, fcolor, length, petals)
stem(tortoise, length)
rainbow = turtle.Turtle()
rainbow.hideturtle()
flower(rainbow, 'yellow', 200, 6)
screen = rainbow.getscreen()
screen.exitonclick()