-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.py
116 lines (107 loc) · 3.86 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import sys
import keyboard
from colorama import Fore, init
init(autoreset = True)
def addition():
try:
firstnumber = int(input(Fore.GREEN + "Enter the First Number: "))
secondnumber = int(input(Fore.GREEN + "Enter the Second Number: "))
print("")
result = firstnumber + secondnumber
except ValueError:
print(Fore.RED + "Oops!")
print(Fore.RED + "We cand Add Number and String")
print(Fore.RED + "Try Again")
addition()
else:
print(Fore.CYAN + "Addition of "+Fore.GREEN+str(firstnumber)+Fore.CYAN+" and "+Fore.GREEN+str(secondnumber)+Fore.CYAN+" is "+Fore.BLUE+str(result))
print(Fore.RED+"EXECUTION COMPLETED")
print("")
choose_option()
def subraction():
try:
firstnumber = int(input(Fore.GREEN+"Enter the First Number: "))
secondnumber = int(input(Fore.GREEN+"Enter the Second Number: "))
print("")
result = firstnumber - secondnumber
except ValueError:
print(Fore.RED+"Oops!")
print(Fore.RED+"We Cant Subract Number and String")
print(Fore.RED+"Try Again")
subraction()
else:
print(Fore.CYAN + "Subration of "+Fore.GREEN+str(firstnumber)+Fore.CYAN+" and "+Fore.GREEN+str(secondnumber)+Fore.CYAN+" is "+Fore.BLUE+str(result))
print(Fore.RED+"EXECUTION COMPLETED")
print("")
choose_option()
def multiplication():
try:
firstnumber = int(input(Fore.GREEN+"Enter the First Number: "))
secondnumber = int(input(Fore.GREEN+"Enter the Second Number: "))
print("")
result = firstnumber * secondnumber
except ValueError:
print(Fore.RED+"Oops!")
print(Fore.RED+"We can't Multiply Number and String")
print(Fore.RED+"Try Again")
multiplication()
else:
print(Fore.CYAN + "Multiplicatuon of "+Fore.GREEN+str(firstnumber)+Fore.CYAN+" and "+Fore.GREEN+str(secondnumber)+Fore.CYAN+" is "+Fore.BLUE+str(result))
print(Fore.RED+"ECECUTION COMPLETED")
print("")
choose_option()
def division():
try:
firstnumber = int(input(Fore.GREEN+"Enter the First Number: "))
secondnumber = int(input(Fore.GREEN+"Enter the Second Number: "))
print("")
result = firstnumber / secondnumber
except ValueError:
print(Fore.RED+"Oops!")
print(Fore.RED+"We can't Divide Number and String")
print(Fore.RED+"Try Again")
division()
except ZeroDivisionError:
print(Fore.RED+"Oops!")
print(Fore.RED+"We cant divide a number by zero")
division()
else:
print(Fore.CYAN + "Division of "+Fore.GREEN+str(firstnumber)+Fore.CYAN+" and "+Fore.GREEN+str(secondnumber)+Fore.CYAN+" is "+Fore.BLUE+str(result))
print(Fore.RED+"EXECUTION COMPLETED")
print("")
choose_option()
def choose_option():
print(Fore.YELLOW+"1.ADDITION\n2.SUBRACTION\n3.MULTIPLICATION\n4.DIVISION\n5.Exit")
try:
case = int(input(">>>"))
print("")
except ValueError:
print(Fore.RED+"Oops!")
print(Fore.RED+"You had entered a incorect value")
print(Fore.RED+"Try Again!")
choose_option()
else:
if case == 1:
print(Fore.BLUE+"ADDITION")
addition()
elif case == 2:
print(Fore.BLUE+"SUBRACTION")
subraction()
elif case ==3:
print(Fore.BLUE+"MULTIPLICATION")
multiplication()
elif case == 4:
print(Fore.BLUE+"DIVISION")
division()
elif case == 5:
print(Fore.RED+"Thanks For Using Me")
print("")
sys.exit(1)
else:
print(Fore.RED+"Oops!")
print(Fore.RED+"Select Correct Option")
choose_option()
def author():
print(Fore.GREEN+("Script by ")+Fore.RED+("TITAN彡HACKY"))
author()
choose_option()