Question: Create the following program: Description: Draw an initial rectangle in turtle graphics, then solicit user to input to decrease the rectangle by an entered percentage.
Create the following program: Description: Draw an initial rectangle in turtle graphics, then solicit user to input to decrease the rectangle by an entered percentage. Create two constants ANGLE and LENGTH and initialize them with 90 and 200 respectively Create variables named inputPercent and modifiedLength and initialize them with the string start and zero, respectively Draw an initial rectangle (using red pen color) using the constants and a for loop with the range function Stop here and test your program, making sure it works correctly. Create a while loop and loop as long as inputPercent is unequal to zero Use the input function to get a negative percentage value from the user and store it in inputPercent Perform validation on inputPercent to ensure it is less than 0 and greater than or equal to negative 100 If the validation is successful, calculate the modified length by using the constant LENGTH and the inputPercent value (for example, if user enters -25 the modified length is 75% of LENGTH) Within the loop, redraw the rectangle using a black pen, the modifiedLength and constant ANGLE, but otherwise same code as initial rectangle After the loop display a statement that the loop is exited (see output below) Hide the turtle and use the command exitonclick to ensure the turtle window remains open
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
