Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON In this exercise you will compute the number of gallons of paints needed to paint a room. Your computation will assume that the room

PYTHON

In this exercise you will compute the number of gallons of paints needed to paint a room. Your computation will assume that the room is rectangular and you will not take into account openings such as doors and windows.

In questions (1) and (2), write the definitions for functions that meet the indicated specifications. Those function are used in the main progam. In question (3) you will be asked to complete the main program.

(1) Function to compute the wall area given room dimensions.

wall_area(width, length, height) width, length, height are respectively the width, length and height (in feet) of a rectangular room. Returns the area of the walls surface.

wall_area(12, 16.5, 9.25) will return 527.25

(2) Function to compute the amount of paint needed given the area and paint coverage.

gallons_paint(area,sqft_per_gallon) area is area to be painted, sqft_per_gallon is how many square feet a gallon of paint covers. Returns the number of gallons needed to paint a room with given area. The number of gallons needed must be an integer.

gallons_paint(527.25,350) will return 2.

(3) A function get_dimension() has been defined. The function purpose is to allow the user to input one dimension of the room. The paramater will indicate which dimension the user is prompted for. For example, if get_dimension('height') is called, the user will be prompted for the height. Use calls to get_dimension() to get the user input for height, length, and width of the room. Add code where indicated in the template. You must use the indicated variables and you must request the dimension in the given order so your program can pass the tests.

Do not change code after the line #DO NOT MODIFY CODE BELOW

If the input is

9 3 16 6 12 0 350 

The output will end with

Area: 527.25 square feet Gallons of paint needed: 2 gallon(s) 

--------------------------------------------------------------------------------------------------

from math import ceil

# Part (1): Define wall_area() # Part (2); Define gallons_paint()

# Do not modifiy this function definition def get_dimension(side): print('Enter the', side, 'in feet and inches.') print('Enter feet and inches separately.') feet = int(input('How many feet (whole number only): ')) inches = int(input('How many inches (whole number only): ')) return feet + inches /12

if __name__ =='__main__': # Get user input using get_dimension function # Get the height and store it in variable h # Get the length and store it in variable l # Get the width and store it in varaible w

#DO NOT MODIFY CODE BELOW

cov = int(input('How many square feet per gallons? ')) # compute area using the function wall_area area = wall_area(w, l, h) print('Area: %.2f square feet' % area)

# Compute gallons of paint needed gallons = gallons_paint(area,cov) print('Gallons of paint needed: %d gallon(s)' % gallons)

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

Students also viewed these Databases questions

Question

2. How can competencies be used in employee development?

Answered: 1 week ago