-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.py
More file actions
executable file
·33 lines (26 loc) · 894 Bytes
/
calculator.py
File metadata and controls
executable file
·33 lines (26 loc) · 894 Bytes
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
"""
Program to implement simple calculator to do basic operations
"""
if __name__=="__main__":
print "Enter number for any of following operations:\n1-Addition \n2-Subtraction \n3-Multiplication \n4-Division"
function = input()
if function ==1:
print "\nYou chose to perform Addition"
if function ==2:
print "\nYou chose to perform Subtraction"
if function ==3:
print "\nYou chose to perform Multiplication"
if function ==4:
print "\nYou chose to perform Division"
print "Enter two numbers for your operation:\n"
number1=input()
number2=input()
if function ==1:
ans = number1 + number2
if function ==2:
ans = number1 - number2
if function ==3:
ans = number1 * number2
if function ==4:
ans = number1 / number2
print "Answer = %f" %ans