Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
160 views
in Technique[技术] by (71.8m points)

python - Need help making a drawing using recursion

I need to make a code in python that draws the output below using recursion and a function named drawpoly. drawpoly() will take 6 arguments which include a turtle, the length of a side, the number of sides, red, green & blue. While the number of sides is > 2, drawpoly() will recursively call itself decrementing the number of sides by 1 each call. Red will increment by 10, green by 25 & blue by 35 each call. I need to set fillcolor and begin and end fill. I will also need will need to set the screen colormode to be able to use integers to make your colors. [![enter image description here][1]][1]

her's the code I have so far It doesn't print out anything but its a rough outline of what I need to use in the program


wn = trtl.Screen()
def drawpoly(trtl, num_sides, side_length,color):
    numOfSides=8
    num_sides=8
    side_length=100
    color="blue"
    while (numOfSides >2):
        trtl.drawpoly(trtl,num_sides,side_length,color)
        numOfSides -=1

def main():
    return drawpoly

main()


  [1]: https://i.stack.imgur.com/65dS4.png
question from:https://stackoverflow.com/questions/65851756/need-help-making-a-drawing-using-recursion

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...