Skip to content

Commit

Permalink
Merge pull request #871 from Ahmed-Rishad-B-A/patch-1
Browse files Browse the repository at this point in the history
update calculator with power operation
  • Loading branch information
fineanmol committed Oct 14, 2021
2 parents fda34a5 + cd40003 commit 0f3be7e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ def divide(x, y):
"""This function divides two numbers"""

return x / y
def power(x,y):
"""This function divides two numbers"""

return x**y

# take input from the user
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

choice = input("Enter choice(1/2/3/4):")
print("5.Power")
choice = input("Enter choice(1/2/3/4/5):")

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
Expand All @@ -44,5 +48,7 @@ def divide(x, y):

elif choice == '4':
print(num1,"/",num2,"=", divide(num1,num2))
elif choice == '5':
print(num1,"^",num2,"=",power(num1,num2))
else:
print("Invalid input")
print("Invalid input")

0 comments on commit 0f3be7e

Please sign in to comment.