fout = open ("calculator_history.txt", "w")
def calc_mul (a, b):
fout.write(str(a) + "*" + str(b) + "=" + str(a*b) + "\n")
return a * b
def calc_add (a, b):
fout.write(str(a) + "+" + str(b) + "=" + str(a+b) + "\n")
return a + b
def calc_sub (a, b):
fout.write(str(a) + "-" + str(b) + "=" + str(a-b) + "\n")
return a - b
def calc_div (a, b):
fout.write(str(a) + "/" + str(b) + "=" + str(a/b) + "\n")
return a / b
def calc_square (a):
fout.write(str(a) + "^2" + "=" + str(a*a) + "\n")
return a * a
a, b, c, d = 10, 20, 30, 5
print( calc_square( calc_div( calc_mul( calc_sub(a,b), c ), d)))
Comments
Leave a comment