0

So i need to write a function that takes the length of the side and the number of sides of the figure as an argument and then draws a corresponding equilateral shape with the turtle. I have to use this function to draw 20 random shapes (must use random). Also the turtle must move the position in the meantime.

At the moment I have gotten this far, I don't know what to do next tho.

import random
from turtle import*

def func(lenght, nr_of_sides):
    for element in range(20):
        forward(lenght)
        right(nr_of_sides)

a = random.randint(1,100)
b = random.randint(1,100)
func(a, b)

Thanks for help!

0x5453
  • 12,753
  • 1
  • 32
  • 61
  • The corner angles of any equilateral polygon are 360/number of sides. Try making a funciton that draws one shape first, given length and number of sides then worry about doing that 20 times. – JeffUK Feb 11 '22 at 20:48
  • Right now you draw 20 of the same shape because the `randint`s are outside of the `range(20)` loop. You just need to rearrange the code a bit. – 0x5453 Feb 11 '22 at 20:52

0 Answers0