diff --git a/calculator.py b/calculator.py index a3521ec..9fa58b0 100644 --- a/calculator.py +++ b/calculator.py @@ -16,6 +16,14 @@ 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.") @@ -23,7 +31,10 @@ def divide (x, y): 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: ")) @@ -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") - \ No newline at end of file +