Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.11 Ch 3 Program: Painting a wall (Python 3) (1) Prompt the user to input a wall's height and width. Calculate and output the wall's

3.11 Ch 3 Program: Painting a wall (Python 3)

(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.514286 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.514286 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.514286 gallons Cans needed: 1 can(s) Choose a color to paint the wall: red Cost of purchasing red paint: $35 
import math


# Dictionary of paint colors and cost per gallon
paintColors = {
'red': 35,
'blue': 25,
'green': 23
}

# FIXME (1): Prompt user to input wall's width
# Calculate and output wall area
wallHeight = float(input('Enter wall height (feet): '))
print('Wall area:')

# FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

# FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

# FIXME (4): Calculate and output the total cost of paint can needed depending on color
please use python code

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

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions