-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.py
More file actions
44 lines (28 loc) · 962 Bytes
/
Calculator.py
File metadata and controls
44 lines (28 loc) · 962 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
34
35
36
37
38
39
40
41
42
43
44
print("1. +")
print("2. -")
print("3. *")
print("4. /")
num = int(input("Enter operation number to perform (1,2,3,4) : "))
print("")
if num==5 :
print("Enter a valid choice")
elif num==1 :
num1 = float(input("Enter first number : "))
num2 = float(input("Enter second number : "))
result = num1+num2
print(f"{num1} + {num2} = {result}")
elif num==2 :
num1 = float(input("Enter first number : "))
num2 = float(input("Enter second number : "))
result = num1 - num2
print(f"{num1} - {num2} = {result}")
elif num==3 :
num1 = float(input("Enter first number : "))
num2 = float(input("Enter second number : "))
result = num1 * num2
print(f"{num1} * {num2} = {result}")
elif num==4 :
num1 = float(input("Enter first number : "))
num2 = float(input("Enter second number : "))
result = num1 / num2
print(f"{num1} / {num2} = {result}")