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):\n')) wallwidth = float(input('Enter wall width (feet):\n')) wallarea = int(wallHeight*wallwidth) print('Wall area:', wallarea,'square feet') # FIXME (2): Calculate and output the amount of paint needed paintneeded = float(wallarea / 350) print('Paint needed: %f gallons' %(paintneeded)) # FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer cansneeded = round(paintneeded) print('Cans needed:', cansneeded, 'can(s)') # FIXME (4): Calculate and output the total cost of paint can needed depending on color # THESE ARE THE LINES IM HAVING TROUBLE WITH color_chosen = input('Choose a color to paint the wall:\n') dict = {'red': 35,'blue': 25,'green': 23} # I know that they've already made a dictionary up above, but thy're asking me to make a new one so I did print('Cost of purchasing', color_chosen, ":", dict['color_chosen'])
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question