-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcalculator.py
48 lines (37 loc) · 1.18 KB
/
calculator.py
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
# This will be a basic calculator application
# We will make the calulator that will prompt the menu again and again
print("Welcome to the calculator application!!!!")
menu = """
Please choose one of the option from the below available operation:
a) For addition press +
b) For subtraction press -
c) For multiplication press *
d) For division press /
e) For exponent press **
f) For remainder press %
"""
while True:
print(menu)
operator = input()
print("Please enter two valid inputs to perform ", operator, " operations")
a = int(input())
b = int(input())
if operator == '+':
print("Output is ", a+b)
elif operator == '-':
print("Output is ", a-b)
elif operator == '*':
print("Output is ", a*b)
elif operator == '/':
print("Output is ", a/b)
elif operator == '**':
print("Output is ", a**b)
elif operator == '%':
print("Output is ", a%b)
else:
print("Invalid operation!!!")
print("Do you want to continue ?? If yes then write -> Y/y/Yes/yes")
again = input()
if not (again == 'Y' or again == 'Yes' or again == 'y' or again == 'yes'):
break # break always breaks the nearest loop in case of nested
print("Thank you for using the application!!!")