我用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我还没有安装python,所以我使用codepad.org (一个在线编译器)。
我得到以下错误:
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发布于 2011-01-12 13:18:23
问题是,虽然codepad将为您运行代码,但它不会为您提供任何交互性(程序在提示输入时会失败,并且codepad无法提供任何输入,因此会出现错误)。有关该错误的更详细解释,请参阅https://web.archive.org/web/20120104164315/http://pyref.infogami.com/EOFError。
您真的需要继续安装Python并在本地计算机上使用它。http://www.python.org/download/
哦,祝你学习Python好运!
发布于 2011-01-12 13:47:16
在有特殊输入框的地方使用ideone。是的,仍然没有交互性,但方便的stdin。你只需要在那里输入你的数字。
发布于 2021-07-06 12:36:49
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))输出:
Welcome To My Calculator
Enter First Number: 20
Enter Second Number: 10
Your Answer is: 30https://stackoverflow.com/questions/4665558
复制相似问题