Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED THIS PYTHON PROGRAM IN 30 MINUTES PLEASE The program: Write a program that generate random number (1-10) of rectangle objects of various dimension

I NEED THIS PYTHON PROGRAM IN 30 MINUTES PLEASE

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 rectangles 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.

Sample run:

Number of rectangles is 9. [ 96 , 91 ] [ 24 , 29 ] [ 94 , 73 ] [ 61 , 94 ] [ 52 , 6 ] [ 69 , 77 ] [ 28 , 28 ] [ 39 , 1 ] [ 49 , 31 ]

Total area= 29995

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

More Books

Students also viewed these Databases questions