0

Im new to python I use pydroid3, in that I made a simple calculator code but I'm not getting any ans in my output My code:

def calc(a, b): if (choice==1): ans=a+b elif (choice==2): ans=a-b elif (choice==3): ans=a*b elif (choice==4): ans=a/b return ans

print('enter 2 numbers in  calculator\n')
a=input()
b=input()
print('choose:\n', '1 for  addition\n', '2 for  substraction\n', '3 for  multiplication \n', '4 for  division\n')
choice=input()

if (choice==1):
  print('addition of', a , b,  'is:\n')
  print(calc(a, b))
elif (choice==2):
  print('substraction of', a, b,  'is:\n')
  print(calc(a, b))
elif (choice==3):
  print('multiplication of', a, b, 'is:\n')
  print(calc(a, b))
elif (choice==4):
  print('division of', a, b, 'is:\n')
  print(calc(a, b))

In the output:

enter 2 numbers in calculator

1
2
choose:
1 for addition 2 for substraction 3 for multiplication 4 for division

2

[Program finished]

0 Answers0