好的,所以我今天做了一个基本的计算器(今天是我学习编程的第一天),我收到以下代码的错误:
Traceback (most recent call last):
File "C:\Users\Stone\Desktop\unfinished calculator.py", line 42, in <module>
start()
File "C:\Users\Stone\Desktop\unfinished calculator.py", line 26, in start
n1()
TypeError: 'int' object is not callable
以此为代码
x = 1
global n1
global n2
global opp1
def n1():
global n1
n1 = input("Number to perform operation on: ")
n1 = int(n1)
def n2():
global n2
n2 = input("Number to perform operation with: ")
n2 = int(n2)
def opp():
global opp1
opp1 = input("Available operations to perform with number:\n1)Addition\n2)Subtraction\n3)Multiplication\n4)Division\n5)Exit Calculator\nPlease enter number choice (1-5): ")
opp1 = int(opp1)
def add():
print(n1 + n2)
def subtract():
print (n1 - n2)
def multiply():
print(n1 * n2)
def divide():
print(n1 / n2)
def start():
n1()
opp()
n2()
if opp1 == 1:
add()
elif opp1 == 2:
subtract()
elif opp1 == 3:
multiply()
elif opp1 == 4:
divide()
elif opp1 == 5:
x = 0
else:
print("Invalid Choice!")
while x == 1:
start()
有人可以向我解释这里有什么问题吗?