#### print(" Welcome to my calculator ")
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multi(x, y):
return x * y
def divi(x, y):
return x / y
def expon(x, y):
return x ** y
def percent(x, y):
return x % y
def flord(x, y):
return x // y
Calculatorfile = open("my_calculator.txt","+a")
while True:
operation=input("What oparation do you want to perform\n 1.Addition\n 2.Subtraction\n 3.Mulitplaction\n 4.Division\n 5.Exponents\n 6.Percentages\n 7.Floor division\n \n")
num1=float(input("Enter first number"))
num2=float(input("Enter seconed number"))
if(operation== "1"):
print("{} + {} = {}".format(num1, num2, add(num1, num2)))
data = ("{} + {} = {}/n".format(num1, num2, add(num1, num2)))
Calculatorfile.write(data)
elif(operation== "2"):
print("{} - {} = {}".format(num1, num2, subtract(num1, num2)))
data = ("{} - {} = {}/n".format(num1, num2, subtract(num1, num2)))
Calculatorfile.write(data)
elif(operation== "3"):
print("{} * {} = {}".format(num1, num2, multi(num1, num2)))
data = ("{} * {} = {}/n".format(num1, num2, multi(num1, num2)))
Calculatorfile.write(data)
elif(operation== "4"):
print("{} / {} = {}".format(num1, num2, divi(num1, num2)))
data = ("{} / {} = {}/n".format(num1, num2, divi(num1, num2)))
Calculatorfile.write(data)
elif(operation== "5"):
print("{} ^ {} = {}".format(num1, num2, expon(num1, num2)))
data = ("{} ^ {} = {}/n".format(num1, num2, expon(num1, num2)))
Calculatorfile.write(data)
elif(operation== "6"):
print("{} % {} = {}".format(num1, num2, percent(num1, num2)))
data = ("{} % {} = {}/n".format(num1, num2, percent(num1, num2)))
Calculatorfile.write(data)
elif(operation== "7"):
print("{} // {} = {}".format(num1, num2, flord(num1, num2)))
data = ("{} // {} = {}/n".format(num1, num2, flord(num1, num2)))
Calculatorfile.write(data)
reDo = input("Go Again? press <Enter> for yes, or n for no")
if reDo == "n" or reDo == "N":
print("Goodbyeee")
Calculatorfile.write(" \n")
Calculatorfile.close()
break