Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Stuck on a Python question, please help! Program Specifications In this lab you are asked to calculate and print occupancy related information for two apartment

Stuck on a Python question, please help!

image text in transcribed

image text in transcribed

Program Specifications In this lab you are asked to calculate and print occupancy related information for two apartment buildings based on user input. The input will be the number of single bedroom apartments and double bedroom apartments in each apartment building. The program should then calculate and print the total occupancy of each building and average occupancy per apartment in each building. Then the same information should be printed for the combination of the two apartment buildings. To calculate the total occupancy, a single bedroom apartment can have two occupants and a double bedroom apartment can have four occupants. Sample run The user inputs are 6, 4, 3, and 5 Number of single bedrooms (Building 1): 6 Number of double bedrooms (Building 1): 4 Number of single bedrooms (Building 2): 3 Number of double bedrooms (Building 2): 5 === Building 1 === Total single bedroom apartments: 6 Total double bedroom apartments: 4 Total occupancy: 28 Average occupancy per apartment: 2.80 === Building 2 === Total single bedroom apartments: 3 Total double bedroom apartments: 5 Total occupancy: 26 Average occupancy per apartment: 3.25 === Building 1 and 2 === Total single bedroom apartments: 9 Total double bedroom apartments: 9 Total occupancy: 54 Average occupancy per apartment: 3.00 Required program decomposition You are required to include the following functions in your program calc_occupancy (total_single, total_double) This function calculates and returns the total occupancy based on the two parameters that it accepts: 1) the total number of single bedroom apartments (total_single) and 2) the total number of single bedroom apartments (total_double). As previously stated, a single bedroom apartment can have two occupants and a double bedroom apartment can have four occupants. calc_avg_occupancy (total_single, total_double, total_occupancy) This function calculates and returns the average occupancy per apartment based on the three parameters that it accepts: 1) the total number of single bedroom apartments (total_single), 2) the total number of single bedroom apartments (total_double), and 3) the total occupancy of the rooms (total_occupancy). print_info(title, total_single, total_double, total_occupancy, average) This function prints information based on the five parameters that it accepts: 1) a title for the printout (title), 2) the total number of single bedroom apartments (total_single), 3) the total number of single bedroom apartments (total_double), 4) the total occupancy of the rooms (total_occupancy), and 5) average occupancy per apartment (average). A further requirement: the average occupancy rate must be printed with two digits after the decimal point. For example, if the the arguments passed are in this order): Building 1, 6, 4, 28, and 2.8, then print_info should print the following text. Note that there should be an additional empty line at the end at the end of the printout, which is not shown below. For example, if the the arguments passed are in this order): Building 1, 6, 4, 28, and 2.8, then print info should print the following text. Note that there should be an additional empty line at the end at the end of the printout, which is not shown below. === Building 1 === Total single bedroom apartments: 6 Total double bedroom apartments: 4 Total occupancy: 28 Average occupancy per apartment: 2.80 calc_and_print_apt_stats (title, total_single, total_double) This function should call the previously describe functions in order to generate an output like the sample run. This function accepts three parameters: 1) a title for the printout (title), 2) the total number of single bedroom apartments (total_single), 3) and the total number of single bedroom apartments (total_double). Notes You must make calls to the functions above in the main function. All your statements must be part of one of the functions described above (including the main function). Points will be deducted if a statement is not part of any of these functions

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

13-6 How will MIS help my career?

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago