1

I'm trying to make a calculator that converts calories, weight, and exercises, to amount of time you need to exercise for my school project. It gives me the error below on the first line that is not a comment.

I need to know why it gives me this error and also how to fix it.

I would also like to know any other errors and how to fix those.

Here is the code:

#Imports
#Variables
#Functions
#Game

calories = input("How many calories or what food item ? : ")
weight = input("How much do you weigh? : ")
exercise = input("Enter your exercise or calories burned per pound per minute : ")

if calories < 0 :
    calories = 0
if weight < 0 :
    weight = 0

if exercise == "sitting" :
    exercise = .009
if exercise == "basketball" :
    exercise = .063
if exercise == "walking" :
    exercise = .019
if exercise == "softball" :
    exercise = .0038
if exercise == "weight training" :
    exercise = .039
if exercise == "jogging" :
    exercise = .063
if exercise == "bowling" :
    exercise = .023
if exercise == "fast biking" :
    exercise = .045
if exercise == "swimming" :
    exercise = .064
if exercise == "slow biking" :
    exercise = .029
if exercise == "ice skating" :
    exercise = .53
if exercise == "soccer" :
    exercise = .076
if exercise == "golf" :
    exercise = .033
if exercise == "sitting" :
    exercise = .009
if exercise == "tennis" :
    exercise = .061
if exercise == "jump rope" :
    exercise = .083

if calories == "big mac" :
    calories = 550
if calories == "large fries" :
    calories = 500
if calories == "large coca-cola" :
    calories = 310
if calories == "salad no dressing" :
    calories = 20

answer = calories / (weight * exercise)
minuteanswer = answer
houranswer = 60 / minuteanswer
dayanswer = 24 / houranswer

print("It will take you " + minuteanswer + " minutes, " + houranswer + " hours, or " + dayanswer + " days to burn off those calories with your chosen execise.")

print("TA-DA!!!!!!")

Here is the error:

How many calories or what food item ? : Traceback (most recent call last):
  Line 6, in <module>
    calories = input("How many calories or what food item ? : ")
EOFError

Here is the updated code after fixing all errors:

#Imports
#Variables
#Functions
#Game

calories = input("What food item ? : ")
weight = input("How much do you weigh? : ")
exercise = input("Enter your exercise : ")

if exercise == "sitting" :
    exercise = 0.009
elif exercise == "basketball" :
    exercise = 0.063
elif exercise == "walking" :
    exercise = 0.019
elif exercise == "softball" :
    exercise = 0.0038
elif exercise == "weight training" :
    exercise = 0.039
elif exercise == "jogging" :
    exercise = 0.063
elif exercise == "bowling" :
    exercise = 0.023
elif exercise == "fast biking" :
    exercise = 0.045
elif exercise == "swimming" :
    exercise = 0.064
elif exercise == "slow biking" :
    exercise = 0.029
elif exercise == "ice skating" :
    exercise = 0.53
elif exercise == "soccer" :
    exercise = 0.076
elif exercise == "golf" :
    exercise = 0.033
elif exercise == "sitting" :
    exercise = 0.009
elif exercise == "tennis" :
    exercise = 0.061
elif exercise == "jump rope" :
    exercise = 0.083
else :
    exercise = .009

if calories == "big mac" :
    calories = 550.0
elif calories == "large fries" :
    calories = 500.0
elif calories == "large coca-cola" :
    calories = 310.0
elif calories == "salad no dressing" :
    calories = 20.0
else :
    calories = 550

answer = calories / (float(weight) * exercise)
minuteanswer = answer
houranswer = 60 / minuteanswer

print("It will take you " ,minuteanswer ," minutes or " ,houranswer ," hours to burn off those calories with your chosen execise.")

print("TA-DA!!!!!!")
15
  • 2
    How are you running it? Commented May 6, 2015 at 21:46
  • How are you running this code? It looks like standard input is closed immediately. Commented May 6, 2015 at 21:46
  • 6
    You think you are using Python 3 but you are not. This error happens when you use Python 2 because input automatically tries to eval whatever you give it, so if you hit return it gets nothing and produces EOFError. Everyone I tell this to swears they are really using Python 3, but I'm always right. You can prove it to yourself by calling raw_input instead. This will fix your problem if you are really on Python 2, but cause NameError on Python 3. :) Commented May 6, 2015 at 21:49
  • Are you using an IDE when running the script, or are you launching it via a shell? Commented May 6, 2015 at 21:51
  • 2
    @BradyW please update the question or make a new one. That way is easier to look at the code and give you an answer Commented May 6, 2015 at 22:24

1 Answer 1

3

The answer to the original question is that I wasn't using the right IDE and the Python version was 2 instead of 3.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for taking the time to answer your own question and help the community!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.