Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program (draw_shapes.py) that uses functions to draw a triangle, a square, or all two shapes, as chosen by the user. Your program

Write a Python program (draw_shapes.py) that uses functions to draw a triangle, a square, or all two shapes, as chosen by the user.

Your program should contain three functions:

(1) draw_triangle(num): This function takes in an integer as a parameter, and draws a solid right-angle triangle (made of asterisks) of that height and width. This function should have no return statement. (Submit for 3 points)

(2) draw_square(num): This function takes in an integer as a parameter, and draws a solid square (made of asterisks) of that height and width. This function should have no return statement. (Submit for 3 points)

(3) __main__: In the main, you do the following:

a. Gets a positive integer (greater than 0) as an input from the user. Reprompt until the user enters a positive integer greater than 0.

b. Asks the user to choose which shape: triangle, square, or all to select all two shapes. Reprompt until the user enters a valid choice.

c. Calls the appropriate function(s) to print what the user requested. (Submit for 4 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

8. Explain competency models and the process used to develop them.

Answered: 1 week ago