0

I built a very simple addition calculator in python:

#This program will add two numbers entered in by the user

print "Welcome!"

num1 = input("Please enter in the first number to be added.")
num2 = input("Please enter in the second number to be added.")

sum = num1 + num2

print "The sum of the two numbers entered is: ", sum

I haven't setup python yet, so I'm using codepad.org (an online compiler).

I get the following error:

Welcome!
Please enter in the first number to be added.

Traceback (most recent call last):
Line 5, in <module>
  num1 = input("Please enter in the first number to be addeded.")
EOFError
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
kachilous
  • 2,499
  • 11
  • 42
  • 56

3 Answers3

7

The problem is that, while codepad will run the code for you, it doesn't give you any interactivity (the program fails when it prompts for input, and codepad can't give it any input, so it gets an error). See https://web.archive.org/web/20120104164315/http://pyref.infogami.com/EOFError for a more thorough explanation of the error.

You really need to just go ahead and install Python and work with it from your local machine. http://www.python.org/download/

Oh, and good luck learning Python!

twasbrillig
  • 17,084
  • 9
  • 43
  • 67
Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
  • Oh ok. I was downloading python while trying to compile the code, now that its finished I'm gonna go ahead and install it. Thanks! – kachilous Jan 12 '11 at 05:43
3

Use ideone where you have special input frame. Yes still no interactivity but convenient stdin. You will need just type your numbers in there.

gorlum0
  • 1,425
  • 12
  • 12
-1
print("Welcome To My Calculator")


num1 = int(input('Enter First Number: '))
num2 = int(input('Enter Second Number: '))
Sum = 'num1 + num2'
print ('Your Answer is: ' + str(num1+num2))

Output:

Welcome To My Calculator
Enter First Number: 20
Enter Second Number: 10
Your Answer is: 30
Josef
  • 2,869
  • 2
  • 22
  • 23