Question: PYTHON for beginners. I need help with part 4. Thank you. (This is a re-post since my code was exactly copied and pasted, but posted

PYTHON for beginners. I need help with part 4. Thank you.

(This is a re-post since my code was exactly copied and pasted, but posted as Answered.)

Part 4. Driver code: Loop to call the getSize function, the getNumSides function, and the drawPolygon function to keep drawing polygons, until the user chooses a size of 0. Each time that a new polygon is drawn, the previous polygon should be cleared from screen.

PYTHON for beginners. I need help with part 4. Thank you. (This

This is my unfinished code -- part 4 is wrong and does not run as assigned: to keep drawing polygons (one at a time), until the input of the user is 0. Each drawn polygon should disappear before the next polygon is drawn.

#1. def drawPolygon (t, n, length): t.color ("blue") t.begin_fill () t.fillcolor("blue") for i in range(n): t.lt(360) t.fd(length) t.end_fill() #2. def getSize (): length = int(input ("Enter size of polygon (50-150): ")) if length == 0: return length while 50>length or length>150: print ("Error: size must be between 50 and 150") length = int(input ("Enter size of polygon (50-150): ")) return length

#3. def getNumSides (): n =int(input ("Enter number of sides of polygon (3-10): ")) while 3 >n or n>10: print ("Error: sides must be between 3 and 10") n =int(input ("Enter number of sides of polygon (3-10): ")) return n

#4. from turtle import* import time t=Turtle ()

length=getSize () n = getNumSides ()

if length == 0: bye () while length >0: drawPolygon (t, n, length) time.sleep(3) t.reset()

fills the polygon with the same color as the border. You can choose a color for the polyg on 2. getSize function input: nothing return: the size that the user enters The function prompts the user and reads in the size of the polygon. The function checks that the input size is either 0 or is a number between 50 and 150, inclusive. Otherwise it keeps prompting the user until it gets a valid size 3. getNurmsides function input: nothing return the number of sides that the user enters The function prompts the user and reads in the number of sides for the polygon. The function checks that the input number is between 3 and 10, inclusive, otherwise it keeps prompting the user until it gets a valid number. 4. Driver code Loop to call the getsize function, the getNumsides funcion, and the draw Polygon function to keep drawing polygons, until the user chooses a size of 0. Each time that a new polygon is drawn, the previous polygon should be dearedfrom saeen. Example output, with input error: Enter size of polygon (50-150) 40 Error: size must be between 50 and 150 Enter size of polygon (50-150) 200 Error size must be between 50 and 150 Enter size of polygon (50-150) 50 Enter number of sides of polygon (3-10): 8 Enter size of polygon (50-150) 90 Enter number of sides of polygon (3-10) 2 Error: size must be between 3 and 10 Enter number of sides of polygon (3-10) 12 Error size must be between 3 and 10 Enter number of sides of polygon (3-10) 5 Enter size of polygon (S0-150) -2 Error: size must be between 50 and 150 Enter size of polygon (50-150) 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!