# Python Math Calculator

Now we dive into math operations.  It is very simple, just like basic math.  Python keeps it intuitive.  These are the basic math operations.

– subtraction
* multiplication
/  division
** power of
%  modulus

In IDLE you can just type 1+1 and it outputs 2.

Math Calulator

Below is a basic calculator code.  See if you can figure out how it works by reading the code.  Copy and paste the code into PyCharms or text editor.  Run it a few times to see what it does.

```#defining the add function that takes 2 arguments num1 and num2
return num1 + num2

#defining the minus function that takes 2 arguments num1 and num2
def subtract(num1, num2):
return num1 - num2

#defining the multiply function that takes 2 arguments num1 and num2
def multiply(num1, num2):
return num1 * num2

#defining the divide function that takes 2 arguments num1 and num2
def divide(num1, num2):
return num1 / num2

#defining the to the power of function that takes 2 arguments num1 and num2
def powerOf(num1, num2):
return num1 ** num2

#defining the to the power of function that takes 2 arguments num1 and num2
def modulus(num1, num2):
return num1 % num2

#main is the last thing in a Python program and is like a command post
def main():
operation = input("What math do you want to perform?  (+, -, *, /, **, %):  ")
if(operation != '+' and operation != '-' and operation != '*' and operation != '/' and operation != '**' and operation != '%'):
#invalid operation choice
print('You must enter a valid operation.')
else:
var1 = int(input("Enter first number:  "))
var2 = int(input("Enter second number:  "))
if(operation == '+'):
elif(operation == '-'):
elif(operation == '*'):
elif(operation == '/'):