## Need help with gallons of paint problem please

For students who are taking a programming course, may be restricted in what they can use, or have other unusual limitations on solving their task.

### Need help with gallons of paint problem please

program:
250.0 square feet wall will need:
0.714285714286 gallons of paint

Code: Select all
`wall_area = 250.0gallons_paint = 0.0wall_area = float(input('What is the area of the wall (in square feet)?'))gallons_paint = wall_area*1.0/350;print(str(wall_area)+" square feet will need:"+ str(gallons_paint)+" gallons of paint")    print(wall_area, 'square feet wall will need:')print(gallons_paint, 'gallons of paint')`

Result:

What is the area of the wall (in sq ft)?Traceback (most recent call last):
File "main.py", line 4, in
wall_area = float(input('What is the area of the wall (in sq ft)?'))
EOFError: EOF when reading a line

The solution is the middle 3 lines and there's something wrong with the first line but I cannot figure it out. Any help is greatly appreciated!!

callia

Posts: 4
Joined: Mon Sep 12, 2016 3:36 pm

### Re: Need help with gallons of paint problem please

How is your program getting its input?
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

### Re: Need help with gallons of paint problem please

The only way I can reproduce something close to your error is when I input an empty line ([enter] without any data, or empty line in input file), executing your code under Python v2 (despite the Python v3 syntax in the print() calls).
This forum has been moved to http://python-forum.io/. See you there.

Ofnuts

Posts: 2659
Joined: Thu May 14, 2015 9:46 am
Location: Paris, France, EU, Earth, Solar system, Milky Way, Local Cluster, Universe #32987440940987

### Re: Need help with gallons of paint problem please

I stumbled upon...

I started taking away lines of code until I was left with:

Code: Select all
`wall_area = 250.0gallons_paint = 0.0gallons_paint = wall_area*1.0/350;print(wall_area, 'square feet wall will need:')print(gallons_paint, 'gallons of paint')`

and then I was successful!

callia

Posts: 4
Joined: Mon Sep 12, 2016 3:36 pm

### Re: Need help with gallons of paint problem please

Code: Select all
`wall_area = 250.0    # Do not needgallons_paint = 0.0   # Do not needwall_area = float(input('What is the area of the wall (in square feet)?'))gallons_paint = wall_area*1.0/350;    # Do not need to multiply by 1.0, do not need trailing semi-colanprint(str(wall_area)+" square feet will need:"+ str(gallons_paint)+" gallons of paint")    print(wall_area, 'square feet wall will need:')print(gallons_paint, 'gallons of paint')`

and using the print format, we can scrunch it up to:
Code: Select all
`wall_area = float(input('What is the area of the wall (in square feet)?'))gallons_paint = wall_area / 350print("A {} square foot wall will need:\n{} gallons of paint".format(wall_area, gallons_paint))`

Not sure where you can buy 0.714285714286 gallons of paint though . Are you allowed to import modules?
THIS FORUM WILL BE CLOSING OCT 1, 2016. PLEASE STOP BY AND REGISTER AT THE NEW LOCATION
http://python-forum.io

sparkz_alot

Posts: 269
Joined: Sat Dec 06, 2014 2:55 pm
Location: US

### Re: Need help with gallons of paint problem please

The code shown is python3 code but I expect you are using python2, either change to python 3 or change
Code: Select all
`input`

to
Code: Select all
`raw_input`

and the prints remove the ()
Code: Select all
`print('some text')`

to
Code: Select all
`print 'some text'`
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

Yoriz

Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK