## Computer Club Activity – Calculator

2019-10-15

In computer club today we started to build a simple text-based calculator that can perform four functions: Add, Subtract, Multiply, and Divide. Students were encouraged to download and install Python if they have not already done so and to work on completing the code we started.

``````#Computer Club - Simple Python Calculator

return(a+b)

def subtract(a,b):
return(a-b)

Req=input("Enter A to add, B to Subtract, C to Multiply, D to Divivde")
return(Req)

def main():
if(UserReq=="A"):
Num1=int(input("Enter the first number: "))
Num2=int(input("Enter the second number: "))
print (str(Num1)+" + "+str(Num2)+" = "+str(ans))
elif (UserReq=="B"):
#Code to Subtract
Num1=int(input("Enter the first number: "))
Num2=int(input("Enter the second number: "))
ans=subtract(Num1,Num2)
print (str(Num1)+" - "+str(Num2)+" = "+str(ans))
elif (UserReq=="C"):
#Code to Multiply
elif (UserReq=="D"):
#Code to Divide
else:
print("Response not understood!")

main()    ``````