TheRodMeister
8/17/2018 - 1:58 AM

## Basic Calculator

A basic calculator that does addition, subtraction, multiplication, division and ends if you type in the word 'end. '

10
+
4.234
14.234

100
*
5
500.0

10.133342
-
2
8.133342

50
/
2
25.0

end
calculator finished
number of times used: 4
#create counter, start at 0
inputCount = 0

#infinite loop to continue caclulations
while True:

#take first user input, if string 'end', break loop
firstNumberUserInput = input()  # takes in as string so we could break if some1 types in end.
if firstNumberUserInput == 'end':
break

#otheerwise take operator, second input, and convert first input to int
else:
operatorUserInput = input()
secondUserInput = float(input()) #use float so we can work with decimals
firstNumberUserInput = float(firstNumberUserInput)#<<<<--have to convert then reassign back into variable

#check what operator, and perform corresponding operation, then print solution
if operatorUserInput == '*':
print(firstNumberUserInput * secondUserInput)
elif operatorUserInput == '+':
print(firstNumberUserInput + secondUserInput)
elif operatorUserInput == '-':
print(firstNumberUserInput - secondUserInput)
elif operatorUserInput == '/':
print(firstNumberUserInput / secondUserInput)
else:
print('invalid operator input')

# add one to the counter after each loop finishes
inputCount += 1

#print a break at end of each line signifying new loop
print('\n')

#print calculator finished and how many times calculator was used
print('calculator finished')
print('number of times used: ' + str(inputCount)) #<<<-- convert to str bec int does not concat with str