For this program you will complete a "rectangle simulator" program that uses four functions you will write. The full program has been written below - all you need to do is successfully write the four...


For this program you will complete a<br>

Extracted text: For this program you will complete a "rectangle simulator" program that uses four functions you will write. The full program has been written below - all you need to do is successfully write the four functions described here. Refer to the IPO notation below when writing these functions (note: you can just copy the IPO directly into your code to document your functions): * function: # input: compute_area_of_rectangle length (integer) and width (integer) # processing: computes the area of the described rectangle # output: described rectangle (integer) returns the area of the # function: # input: compute perimeter_of_rectangle length (integer) and width (integer) # processing: computes the perimeter of the described rectangle # output: returns the perimeter of the described rectangle (integer) # function: draw_rectangle length (integer) and width # input: (integer) # processing: constructs the rectangle using a series of "*" characters (see below for a sample 4 by 3 rectangle:) *** *** # output: This next function is used to encapsulate an input validation loop -- so you can get input and validate it all in one function call. returns the rectangle (string) # function: get_input # input: (String), a low value (integer) and a high a prompt to ask the user value (integer) # processing: continually prompts the user for input, using the supplied prompt. if the user does not enter an integer within the defined range the function will re-prompt them # output: returns the integer the user supplied (int) Here is the code for the main body of your program, Once you've written the above functions, paste this code into your Python file and the program should run using your functions. length = get_input ("Enter a length between 3 and 10", 3, 10) = get_input("Enter a width between 3 and 10", 3, 10) width = compute_area_of_rectangle (length, width) area perim = compute_perimeter_of_rectangle (length, width) print ("Area:", area, "; Perim:", perim) rect = draw_rectangle (1ength, width) print (rect) Note: Take a careful look at the IPO specification for the draw_rectangle function. It is supposed to return a string, which is the "image" of the rectangle. You're not supposed to print within the function -- instead you should return the fully composed string so the calling code can print it. This is going to be true for almost all functions I specify in this course, and is generally how you will use functions in programming. Almost always, you'll have functions that put together the information for output, and you will do the actual output somewhere else in the program.
Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here