This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathCalculator.py
155 lines (135 loc) · 4.27 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
def addition():
a = float(input("Enter First Number:-"))
b = float(input("Enter Second Number:-"))
print("Sum of Entered numbers is ", a+b)
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
addition()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def substract():
a = float(input("Enter First Number:-"))
b = float(input("Enter Second Number:-"))
print("Result of Substraction is ", a-b)
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
substract()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def multiply():
a = float(input("Enter First Number:-"))
b = float(input("Enter Second Number:-"))
print("Product of These numbers is ", a*b)
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
multiply()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def division():
a = float(input("Enter Numenator:-"))
b = float(input("Enter Denominator:-"))
print("the result of Division is ", a/b)
print("Integral part is ", int(a/b))
print("Remainder is", a % b)
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
division()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def power():
a = int(input("Enter Base:-"))
b = int(input("Enter Power:-"))
print("Result is ", pow(a, b))
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
power()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def runner():
print("1.)For Addition.\n2.)For Substraction.\n3.)For Multiplication\n"
"4.)For Division\n5.)For Power Calculation\n6.)To get ASCII Code.\n7.)For Decimal to binary."
"\n8.)For Decimal to Octal.\n9.)For Decimal to Hexadecimal.")
k = int(input("Enter The Choice:-"))
if k == 1:
addition()
elif k == 2:
substract()
elif k == 3:
multiply()
elif k == 4:
division()
elif k == 5:
power()
elif k == 6:
asc()
elif k == 7:
binar()
elif k == 8:
octal()
elif k == 9:
hexadecimal()
else:
print("You Have Enter a Wrong Input!!")
def asc():
a = input("Enter The Character:-")
print("ASCII Value is ", ord(a))
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
asc()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def binar():
a = int(input("Enter Decimal Number:-"))
b = bin(a)
print("Binary Output for this decimal number is", b[2:])
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
binar()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def octal():
a = int(input("Enter Number in decimal number number system:-"))
b = oct(a)
print("Octal output for the given number is ", b[2:])
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
octal()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
def hexadecimal():
a = int(input("Enter Number in Decimal number system:-"))
b = hex(a)
print("Hexadecimal output for this number is ", b[2:])
print("1.)To calculate Again.\n2.)To exit program.\n3.)For main menu.")
a = int(input("Enter the Choice:-"))
if a == 1:
hexadecimal()
elif a == 3:
runner()
else:
print("See you later!!Have a Nice day.")
runner()