Question: Design a Python program that draws four different shapes. Your program will draw one of the four possible shapes depending on the user's choice: a
Design a Python program that draws four different shapes. Your program will draw one of the four possible shapes depending on the user's choice: a line, a triangle, a square, or a rectangle. Your program will prompt the user to enter their choice of shape: 'l' for 2 line, 't' for triangle , 's' for square, and 'r' for rectangle. If a user enters a character that is not 'l', 't', or 's', 'r', the program should display a message indicating that the user's choice was an incorrect type of shape. If the user enters a valid choice, your program will then prompt the user to enter the size of the shape. This will be the length of the line, or the length of the side of the square, or the triangle. When the user's choice is to draw a rectangle, your program should prompt for both the length and the width of the rectangle. You should use for or while loops to implement your program. You need to use nested loops to draw the square, the rectangle, and the triangle. Also, your program should be general enough to draw shapes of different sizes. Your program should check for invalid input for the shape sizes such as 0 or negative numbers and print out a message indicating the size was invalid. To draw a straight line made of characters, you can use the new line suppression operator in the print statements. For example, if you do not want each new output character to go to a new line, you can use: print("*", end="") Note in the below sample run for the triangle, white spaces have been printed between the stars to make the triangle shape appear less skewed. However, no marks will be deducted if you do not add white spaces between the stars for any of the shapes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
