-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise.py
More file actions
executable file
·46 lines (31 loc) · 1.02 KB
/
exercise.py
File metadata and controls
executable file
·46 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''
>>> The Calculator assignment
1) Take three inputs from a user : a, b, c
2) a and b should be operands to perform arithmetic
operations
3) c should be the choice of operation the user would
want to perform. (+, -, %, *, **)
4) Calculate and print each output for the operations
5) get records from the user until the user enters
'end' to stop the program
'''
running = True
while running:
inputA = int(raw_input('Enter 1st Operand\n'))
inputB = int(raw_input('Enter 2nd Operand\n'))
operator = raw_input('Enter the operation to perform\n')
if operator == '+':
print 'Sum is ', (inputA + inputB)
elif operator == '-':
print 'Subtraction is ', (inputA - inputB)
elif operator == '%':
print 'Remainder is ', (inputA % inputB)
elif operator == '*':
print 'Multiplication is ', (inputA * inputB)
elif operator == '**':
print 'Power is ', (inputA ** inputB)
else:
print 'Operator not defined'
end = raw_input('Enter end to exit or press enter to continue\n')
if end == 'end\n':
running = False