# Computer 12 Python Update

Today we finished our introduction to programming using Python.  Our main objective in this segment is to learn basic programming concepts, including output, input, looping, conditionals, variables, and functions.  The culmination of this segment of instruction was building a simple text-based calculator. Here is a sample of one of our calculators:

result=a+b
return(result)
#subtract
def subtract(a,b):
result=a-b
return(result)
#multiply
def multiply(a,b):
result=a*b
return (result)
#divide
def divide(a,b):
result=a/b
return(result)
#Circumference
def Circumference(r):
circ=2*3.14159*r
return(circ)

#main function
def main():
#set selection = to 1 so the condition to start
#our while loop is true
selection=1
while selection>0:
print("2: Subtract")
print("3: Multiply")
print("4: Divide")
print("5: Circumference")
#get the user input
UserChoice=input("Please make a choice or 0 to exit: ")
#convert it to an integet
selection=int(UserChoice)
#if the choice is 0 we are finished!
if(selection==0):
print ("Goodbye")
elif selection>0 and selection<5: #an operation requiring 2 numbers
#Do Math!
#Get 2 Numbers and convert them to integers
num1=int(input("Enter the first number: "))
num2=int(input("Enter the second number: "))
#perform the desired operation
if selection==1:
if selection==2:
x=subtract(num1,num2)
if selection==3:
x=multiply(num1,num2)
if selection==4:
x=divide(num1,num2)
#display the result
print("The result of your operation is: ",x)
elif selection==5: # we only need the radius to calculate the Circumference