Question: Goals: Developing problem-solving skills, checking validity of input, and using multi-branched decision structures. Do not use lists (arrays), tuples or dictionaries. Problem: You are going

Goals: Developing problem-solving skills, checking validity of input, and using multi-branched decision structures. Do not use lists (arrays), tuples or dictionaries.

Problem: You are going to develop a program that will allow the user to draw polygons with different number of sides using different pen colors, and with different lengths of the sides. Your program should prompt the user to enter the number of sides which should be a whole number from 3 to 12 inclusive. Robustly check that the user entered a value in that range (you do not have to check that the user entered a whole number because you should have stored the input as a whole number). Next provide the user a menu of at least 10 colors (e.g. 1 for blue, 2 for yellow etc.). Robustly check that the selected a correct choice. Next ask the user if he/she wants a small, medium or large polygon and robustly confirm that he/she enters a correct choice. Then draw a polygon with the selected size (for small use a side length of 20, for medium use length of 50, and for large use a length of 90), color, and number of sides. Use a pen size of 6 for the drawing. Finally ask the user if he/she would like to create a new polygon. If so, clear the turtle window, and ask the user to enter the choices again. The user should be able to draw as many polygons as he/she would like.

*Do not use any concepts beyond Chapter 4 of Python Fourth Edition by Tony Gaddis (i.e. no functions).

*Do not use any breaks please, as breaks are not aloud to be used in my course

***Can someone please show me how this code can work without the break statements? I already have the code written but need help to revise because 'break' statements are not aloud!

Thank you

import turtle

while(True):

num_side = int(input("Enter the number of sides of the polygon that you want to draw: "))

if num_side <= 12 and num_side >= 3:

break;

else:

print("ERROR: Please enter the sides in range 2 and 12 inclusive")

while(True):

print("Choose color of the polygon: ")

choice = int(input("1 red "+

"2 blue "+

"3 green "+

"4 black "+

"5 yellow "+

"6 brown "+

"7 purple "+

"8 pink "+

"9 orange "+

"10 gray "+

"11 light red "+

"12 light green "+

">> "

))

if choice > 0 and choice < 13:

break

if choice == 1:

color = "red"

elif choice == 2:

color = "blue"

elif choice == 3:

color = "green"

elif choice == 4:

color = "black"

elif choice == 5:

color = "yellow"

elif choice == 6:

color = "brown"

elif choice == 7:

color = "purple"

elif choice == 8:

color = "pink"

elif choice == 9:

color = "orange"

elif choice == 10:

color = "gray"

elif choice == 11:

color = "#550000"

elif choice == 12:

color = "#006600"

while True:

choice = input("Enter the size you want (small, medium or large) : ")

if choice.lower() in ("small", "medium", "large"):

break

if choice.lower() == "small":

sideLen = 20

elif choice.lower() == "medium":

sideLen = 50

elif choice.lower() == "large":

sideLen = 90

pdrawer = turtle.Turtle()

pdrawer.color(color)

pdrawer.width(6)

angle = 360 / num_side

pdrawer.penup()

pdrawer.goto (-50, 50)

pdrawer.pendown()

for _ in range (num_side):

pdrawer.forward(sideLen)

pdrawer.left (angle)

turtle.done()

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!