## 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
def add(a,b):
return(a+b)
def subtract(a,b):
return(a-b)
def menu():
Req=input("Enter A to add, B to Subtract, C to Multiply, D to Divivde")
return(Req)
def main():
UserReq=menu()
if(UserReq=="A"):
Num1=int(input("Enter the first number: "))
Num2=int(input("Enter the second number: "))
ans=add(Num1,Num2)
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()
```