Type Error: Int object is not callable

AtPython

I have an error with my code when I try to run it.

CODE

print("Operations: \n1. Addition \n2. Subtraction \n3: Multiplication \n4. Division")
print("^ Operation 'ID' please enter the id of your choice")
choice = input()
num1 = input("Enter your first number: ")
num2 = input("Enter your second number: ")
def addition(num1, num2):
    num1
    num2
    ans = num1 + num2
    print('Your answer is %s') %(ans)
def subtraction(num1, num2):
    num1
    num2
    ans = num1 - num2
    print('Your answer is %s') %(ans)
def multiply(num1, num2):
    num1
    num2
    ans = num1 * num2
    print('Your answer is %s') %(ans)
def division(num1, num2):
    num1
    num2
    ans = num1 / num2
    print('Your answer is %s') %(ans)
if choice == "1":
    addition
elif choice == "2":
    subtraction
elif choice == "3":
    multiply
elif choice == "4":
    division
else:
    print("Invalid Input")

Everything works until python is called to print the answer.

I am aware of the possible duplicates but none of the code provided there works.

AtPython

Ironically, this has ended up with me writing an answer to my own question with admittedly some help from @ Vignesh Kalai, although hid code was a little off. So before anything else I will address the changes to my code.

Firstly, instead of defining every operation I have linked than with the choice of their "ID"'s.

Secondly, I am using "" + str(x) to print the answers out instead of the admittedly bad idea of using %s.

REVISED CODE

    choice = int(input("Operations: \n1. Addition \n2. Subtraction \n3: Multiplication \n4. Division\n^ Operation 'ID' please enter the id of your choice\n"))
num1 = int(input("Enter your first number: "))
num2 = int(input("Enter your second number: "))
if choice == 1: #Addition
    num1
    num2
    ans = num1 + num2
    print("Your answer is " + str(ans))
elif choice == 2: #Subtraction
    num1
    num2
    ans = num1 - num2
    print("Your answer is " + str(ans))
elif choice == 3: #Miltiplication
    num1
    num2
    ans = num1 * num2
    print("Your answer is " + str(ans))
elif choice == 4: #Division
    num1
    num2
    ans = float(num1) / float(num2)
    print("Your answer is " + str(ans))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

'int' object is not callable error in python

From Dev

'int' object is not callable error in python

From Dev

Getting an error ; 'int' object not callable

From Dev

type error 'class' object not callable

From Dev

Spyder error: 'int' object is not callable but no error in different IDE

From Dev

'int' object is not callable exception

From Dev

Getting error in Python 3.x : TypeError: 'int' object is not callable

From Dev

How to handle non-callable object type of error

From Dev

Flask: TypeError: 'int' object is not callable

From Dev

TypeError: 'int' object is not callable,,, len()

From Dev

TypeError: 'int' object is not callable python

From Dev

TypeError: 'int' object is not callable with Python

From Dev

Int Object Not Callable (Permutations and Combinations)

From Dev

'int' object not callable with int(raw_input(" "))

From Dev

Pygame if event.type == pygame.KEYDOWN() TypeError: 'int' object is not callable

From Dev

Collection object is not callable error with PyMongo

From Dev

Python error: 'dict' object is not callable

From Dev

Understanding error: 'str' object is not callable

From Dev

JavaPackage object is not callable error: Pyspark

From Dev

Float Object is not Callable Error in Python

From Dev

fixed error instance object is not callable

From Dev

Object not callable error accessing array

From Dev

Python Type error: int object not iterable

From Dev

TypeError: 'int' object is not callable - How do I identify what is causing this error?

From Dev

'int' object is not callable when calculating min

From Dev

Python3: TypeError: 'int' object is not callable

From Dev

Python Script TypeError: 'int' object is not callable

From Dev

python threading confusing code 'int' object is not callable

From Dev

'int' object is not callable when calculating min

Related Related

  1. 1

    'int' object is not callable error in python

  2. 2

    'int' object is not callable error in python

  3. 3

    Getting an error ; 'int' object not callable

  4. 4

    type error 'class' object not callable

  5. 5

    Spyder error: 'int' object is not callable but no error in different IDE

  6. 6

    'int' object is not callable exception

  7. 7

    Getting error in Python 3.x : TypeError: 'int' object is not callable

  8. 8

    How to handle non-callable object type of error

  9. 9

    Flask: TypeError: 'int' object is not callable

  10. 10

    TypeError: 'int' object is not callable,,, len()

  11. 11

    TypeError: 'int' object is not callable python

  12. 12

    TypeError: 'int' object is not callable with Python

  13. 13

    Int Object Not Callable (Permutations and Combinations)

  14. 14

    'int' object not callable with int(raw_input(" "))

  15. 15

    Pygame if event.type == pygame.KEYDOWN() TypeError: 'int' object is not callable

  16. 16

    Collection object is not callable error with PyMongo

  17. 17

    Python error: 'dict' object is not callable

  18. 18

    Understanding error: 'str' object is not callable

  19. 19

    JavaPackage object is not callable error: Pyspark

  20. 20

    Float Object is not Callable Error in Python

  21. 21

    fixed error instance object is not callable

  22. 22

    Object not callable error accessing array

  23. 23

    Python Type error: int object not iterable

  24. 24

    TypeError: 'int' object is not callable - How do I identify what is causing this error?

  25. 25

    'int' object is not callable when calculating min

  26. 26

    Python3: TypeError: 'int' object is not callable

  27. 27

    Python Script TypeError: 'int' object is not callable

  28. 28

    python threading confusing code 'int' object is not callable

  29. 29

    'int' object is not callable when calculating min

HotTag

Archive