Question
Python Please! LAB*: Program: Painting a wall Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}')
Python Please!
LAB*: Program: Painting a wall
Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}')
(1) Prompt the user to input a wall's height and width. Calculate and output the wall's area (integer). (Submit for 2 points).
Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet
(2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall (floating point). Assume a gallon of paint covers 350 square feet. Store this value in a variable. Output the amount of paint needed using the %f conversion specifier. (Submit for 2 points, so 4 points total).
Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.51 gallons
(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).
Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.51 gallons Cans needed: 1 can(s)
(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).
Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.51 gallons Cans needed: 1 can(s) Choose a color to paint the wall: red Cost of purchasing red paint: $35
-----------------
height = float(input('Enter wall height (feet): ')) width = float(input('Enter wall width (feet): '))
area = height * width paint_needed = area / 350 cans = int(round(paint_needed))
print('Wall area: ' + str(int(round(area))) + ' square feet') print('Paint needed: %.2f 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 ' + color + ' paint: $' + str(cost))
main.py - 1 1 1 2 height float(input('Enter wall height (feet): ')) 3 width float(input('Enter wall width (feet): ')) 4 5 area = height * width 6 paint_needed area / 350 7 cans = int(round(paint_needed)) 8 9 print('Wall area: + str(int(round(area))) + square feet') 10 print('Paint needed: %.2f gallons' % paint_needed) 11 print('Cans needed: + str(cans) + ' can(s)') 12 13 color input(" Choose a color to paint the wall: ') 14 if color 'red': 15 cost 35 cans 16 elif color 'blue': cost 18 elif color 'green': 19 cost 23 cans 20 else: 21 cost 0 22 print('Cost of purchasing + color + paint: $' + str(cost)) * = 17 25 * cans * 23 Compare output 0/1 Output differs. See highlights below. 15 52 Input blue Enter wall height (feet): Enter wall width (feet): Wall area: 780 square feet Paint needed: 2.23 gallons Cans needed: 2 can(s) Your output starts with Choose a color to paint the wall: Cost of purchasing blue paint: $50 Enter wall height (feet): Enter wall width (feet): Wall area: 780 square feet Paint needed: 2.23 gallons Cans needed: can (s) Expected output starts with Choose a color to paint the wall: Cost of purchasing blue paint: $75Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started