Question

Write a function makePoly(x,y,n,l) that receives a coordinate point (x,y), an integer n representing the desired...

Write a function makePoly(x,y,n,l) that receives a coordinate point (x,y), an integer n representing the desired number of sides (3 to 20) , and an integer l between 10 and 200 pixels, inclusive, representing the length of each side. The function will then use the turtle to draw the requested n-sided polygon at the designated (x,y) coordinate, having sides of length l. Be sure to reject arguments that do not conform to the restrictions given.
(Hint: to get a turtle to go somewhere, use turtleName.goto(x,y)) python

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import turtle """ Program to draw a polygon of side (3, 20) and length 10 to 200 pixels """ # import turtle def makePoly(x: int, y: int, n: int, l: int): # create Turtle() object and move turtle t to x, y co-ordinate t = turtle.Turtle() t.penup() t.goto(x, y) t.pendown() for i in range(n): # for loop iterates till n # move turtle to the length of l # find degree by the formula 360 / n # rotate the turtle by the specified angle t.forward(l) degree = 360 / n t.left(degree) turtle.done() # makePoly(10, 10, 3, 100) # makePoly(100,100,4, 100) # makePoly(100,100,5, 100) # makePoly(100,100,6, 100) makePoly(100,100,7, 100) 
Add a comment
Know the answer?
Add Answer to:
Write a function makePoly(x,y,n,l) that receives a coordinate point (x,y), an integer n representing the desired...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT