99 008
Assignments Done
99%
Successfully Done
In May 2021

# Answer to Question #3392 in Python for mukunda

Question #3392
2) Write a calculator history functionality in continuation of the above example and perform the multiplication, subtraction, division and square of the given numbers and store the result in calculator_history.txt file
1
2011-08-04T12:31:35-0400
fout = open (&quot;calculator_history.txt&quot;, &quot;w&quot;)

def calc_mul (a, b):
fout.write(str(a) + &quot;*&quot; + str(b) + &quot;=&quot; + str(a*b) + &quot;\n&quot;)
return a * b

def calc_add (a, b):
fout.write(str(a) + &quot;+&quot; + str(b) + &quot;=&quot; + str(a+b) + &quot;\n&quot;)
return a + b

def calc_sub (a, b):
fout.write(str(a) + &quot;-&quot; + str(b) + &quot;=&quot; + str(a-b) + &quot;\n&quot;)
return a - b

def calc_div (a, b):
fout.write(str(a) + &quot;/&quot; + str(b) + &quot;=&quot; + str(a/b) + &quot;\n&quot;)
return a / b

def calc_square (a):
fout.write(str(a) + &quot;^2&quot; + &quot;=&quot; + str(a*a) + &quot;\n&quot;)
return a * a

a, b, c, d = 10, 20, 30, 5

print( calc_square( calc_div( calc_mul( calc_sub(a,b), c ), d)))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!