Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@ def multiply(x, y):
def divide (x, y):
""""this function divides two numbers"""
return x/y

def remainder(x,y):
""""this function produce remainder of two numbers"""
return x%y

def power(x,y):
""""left operand raised to the power of right"""
return x**y

# take input from user
print("select operation.")
print("1.add")
print("2.subtract")
print("3.multiply")
print("4.divide")
option=input("Enter option(1/2/3/4): ")
print("5.Remainder")
print("6.Exponent power")

option=input("Enter option(1/2/3/4/5/6): ")

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
Expand All @@ -41,6 +52,12 @@ def divide (x, y):
elif option == '4':
print(num1, "/", num2,"=", divide(num1,num2))

elif option == '5':
print(num1, "R", num2,"=", remainder(num1,num2))

elif option == '6':
print(num1, "^", num2,"=", power(num1,num2))

else:
print("error!invalid input")