Solved by verified expert:Need assistance writing a Python program using classes that generates a random number (1-10) of rectangle objects of various
dimension and prints the rectangles and the total area of all the
rectangles. Assignment instructions attached. Please include comments explaining what everything does.
csc_115_lab_6.docx

Unformatted Attachment Preview

CSC 115 Lab 6
The program:
Write a program that generate random number (1-10) of rectangle objects of various
dimension and prints the rectangles and the total area of all the rectangles.




First, define the Rectangle class. A rectangle is defined by its height and width. It has
compute_area method that returns the rectangle’s area.
Second, create an empty list and append the list with random rectangles with height
and width ranging from 1 to 100.
Last, iterate through the list and total the area of all the rectangles and print the result
as shown the sample run.
Submit your Python program to blackboard.
height
width
Sample run:
Number of rectangles is 9.
[ 96 ,
[ 24 ,
[ 94 ,
[ 61 ,
[ 52 ,
[ 69 ,
[ 28 ,
[ 39 ,
[ 49 ,
91 ]
29 ]
73 ]
94 ]
6]
77 ]
28 ]
1]
31 ]
Total area= 29995

Purchase answer to see full
attachment