This question has been asked before but it appears this one has been giving deci
ID: 3744223 • Letter: T
Question
This question has been asked before but it appears this one has been giving decimal vaules so I need a new answer in python
1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (Submit for 2 points).
(2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet. Store this value in a variable. (Submit for 2 points, so 4 points total).
(3) Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to the nearest gallon. (Submit for 2 points, so 6 points total).
(4) Extend by prompting the user for a color they want to paint the walls. Calculate and output the total cost of the paint cans depending on which color is chosen. Hint: Use a dictionary to associate each paint color with its respective cost. Red paint costs $35 per gallon can, blue paint costs $25 per gallon can, and green paint costs $23 per gallon can. (Submit for 2 points, so 8 points total).
Explanation / Answer
1) height = float(input('Enter wall height (feet): ')) width = float(input('Enter wall width (feet): ')) area = height * width print('Wall area: ' + str(area) + ' square feet') 2) height = float(input('Enter wall height (feet): ')) width = float(input('Enter wall width (feet): ')) area = height * width paint_needed = area / 350 print('Wall area: ' + str(area) + ' square feet') print('Paint needed: %.7f gallons' % paint_needed) 3) height = float(input('Enter wall height (feet): ')) width = float(input('Enter wall width (feet): ')) area = height * width paint_needed = area / 350 cans = round(paint_needed) print('Wall area: ' + str(area) + ' square feet') print('Paint needed: ' + str(paint_needed) + ' gallons') print('Cans needed: ' + str(cans) + ' can(s)') 4) height = float(input('Enter wall height (feet): ')) width = float(input('Enter wall width (feet): ')) area = height * width paint_needed = area / 350 cans = round(paint_needed) print('Wall area: ' + str(area) + ' square feet') print('Paint needed: %.7f gallons' % paint_needed) print('Cans needed: ' + str(cans) + ' can(s)') color = input(' Choose a color to paint the wall: ') if color == 'red': cost = 35 * cans elif color == 'blue': cost = 25 * cans elif color == 'green': cost = 23 * cans else: cost = 0 print('Cost of purchasing red paint: $' + str(cost))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.