Skip to content

Commit

Permalink
Added Calculator code in python
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyas829 committed Oct 3, 2024
1 parent fb47389 commit 0dab46d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Add Code Here/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def add(a,b):
return (a+b)
def sub(a,b):
return (a-b)
def mult(a,b):
return (a*b)
def div(a,b):
return (a//b)


print("1. Addition")
print("2 . Subtraction")
print("3. Multiplication")
print("4. Division")


while True:
choice = int(input("Enter Choice "))
if choice == 1 or choice ==2 or choice ==3 or choice ==4 or choice ==5:
a= int(input("Enter 1st number"))
b= int(input("Enter 2nd number"))
if choice == 1:
print(add(a,b))
elif choice == 2:
print(sub(a,b))
elif choice == 3:
print(mult(a,b))
elif choice == 4:
print(div(a,b))
else:
print("Enter valid choice")
break

0 comments on commit 0dab46d

Please sign in to comment.