Skip to content

Commit 1b07087

Browse files
committed
merge main into fix/js-console-errors
2 parents c02dc91 + 2a2c9bf commit 1b07087

6 files changed

Lines changed: 913 additions & 186 deletions

File tree

README.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,24 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
472472
<sub><b>@anujsharma8d</b></sub>
473473
</a>
474474
</td>
475+
<td align="center" width="120">
476+
<a href="https://github.com/artic2702">
477+
<img src="https://github.com/artic2702.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="artic2702" /><br />
478+
<sub><b>@artic2702</b></sub>
479+
</a>
480+
</td>
475481
<td align="center" width="120">
476482
<a href="https://github.com/ash-heinz">
477483
<img src="https://github.com/ash-heinz.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="ash-heinz" /><br />
478484
<sub><b>@ash-heinz</b></sub>
479485
</a>
480486
</td>
487+
<td align="center" width="120">
488+
<a href="https://github.com/aspartic-gthb">
489+
<img src="https://github.com/aspartic-gthb.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="aspartic-gthb" /><br />
490+
<sub><b>@aspartic-gthb</b></sub>
491+
</a>
492+
</td>
481493
<td align="center" width="120">
482494
<a href="https://github.com/avzuha">
483495
<img src="https://github.com/avzuha.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="avzuha" /><br />
@@ -490,6 +502,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
490502
<sub><b>@ayushyadav0707</b></sub>
491503
</a>
492504
</td>
505+
</tr>
506+
<tr>
493507
<td align="center" width="120">
494508
<a href="https://github.com/codewithakshyaaa">
495509
<img src="https://github.com/codewithakshyaaa.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="codewithakshyaaa" /><br />
@@ -502,8 +516,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
502516
<sub><b>@developer-yash03</b></sub>
503517
</a>
504518
</td>
505-
</tr>
506-
<tr>
507519
<td align="center" width="120">
508520
<a href="https://github.com/dhanushrajvr">
509521
<img src="https://github.com/dhanushrajvr.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="dhanushrajvr" /><br />
@@ -528,6 +540,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
528540
<sub><b>@itsdakshjain</b></sub>
529541
</a>
530542
</td>
543+
</tr>
544+
<tr>
531545
<td align="center" width="120">
532546
<a href="https://github.com/jeetrouth">
533547
<img src="https://github.com/jeetrouth.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="jeetrouth" /><br />
@@ -540,8 +554,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
540554
<sub><b>@jyotish6699</b></sub>
541555
</a>
542556
</td>
543-
</tr>
544-
<tr>
545557
<td align="center" width="120">
546558
<a href="https://github.com/kumudasrip">
547559
<img src="https://github.com/kumudasrip.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="kumudasrip" /><br />
@@ -566,6 +578,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
566578
<sub><b>@mrinmoyChakraborty-mrinox</b></sub>
567579
</a>
568580
</td>
581+
</tr>
582+
<tr>
569583
<td align="center" width="120">
570584
<a href="https://github.com/n1o5">
571585
<img src="https://github.com/n1o5.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="n1o5" /><br />
@@ -578,8 +592,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
578592
<sub><b>@nene-hana</b></sub>
579593
</a>
580594
</td>
581-
</tr>
582-
<tr>
583595
<td align="center" width="120">
584596
<a href="https://github.com/nimkarprachi17">
585597
<img src="https://github.com/nimkarprachi17.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="nimkarprachi17" /><br />
@@ -604,6 +616,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
604616
<sub><b>@parulpaliwal01</b></sub>
605617
</a>
606618
</td>
619+
</tr>
620+
<tr>
607621
<td align="center" width="120">
608622
<a href="https://github.com/pragya-manna">
609623
<img src="https://github.com/pragya-manna.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="pragya-manna" /><br />
@@ -616,8 +630,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
616630
<sub><b>@prasad-0007</b></sub>
617631
</a>
618632
</td>
619-
</tr>
620-
<tr>
621633
<td align="center" width="120">
622634
<a href="https://github.com/priya05-git">
623635
<img src="https://github.com/priya05-git.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="priya05-git" /><br />
@@ -642,6 +654,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
642654
<sub><b>@rishit537</b></sub>
643655
</a>
644656
</td>
657+
</tr>
658+
<tr>
645659
<td align="center" width="120">
646660
<a href="https://github.com/sakshicoded1111">
647661
<img src="https://github.com/sakshicoded1111.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="sakshicoded1111" /><br />
@@ -654,8 +668,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
654668
<sub><b>@sanzzzz-g</b></sub>
655669
</a>
656670
</td>
657-
</tr>
658-
<tr>
659671
<td align="center" width="120">
660672
<a href="https://github.com/shimonenator">
661673
<img src="https://github.com/shimonenator.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="shimonenator" /><br />
@@ -680,6 +692,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
680692
<sub><b>@siri-004</b></sub>
681693
</a>
682694
</td>
695+
</tr>
696+
<tr>
683697
<td align="center" width="120">
684698
<a href="https://github.com/snehacodes-2906">
685699
<img src="https://github.com/snehacodes-2906.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="snehacodes-2906" /><br />
@@ -692,8 +706,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
692706
<sub><b>@snehanair-486</b></sub>
693707
</a>
694708
</td>
695-
</tr>
696-
<tr>
697709
<td align="center" width="120">
698710
<a href="https://github.com/steam-bell-92">
699711
<img src="https://github.com/steam-bell-92.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="steam-bell-92" /><br />
@@ -712,6 +724,14 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
712724
<sub><b>@tanishkakora</b></sub>
713725
</a>
714726
</td>
727+
<td align="center" width="120">
728+
<a href="https://github.com/twinkle0tech">
729+
<img src="https://github.com/twinkle0tech.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="twinkle0tech" /><br />
730+
<sub><b>@twinkle0tech</b></sub>
731+
</a>
732+
</td>
733+
</tr>
734+
<tr>
715735
<td align="center" width="120">
716736
<a href="https://github.com/vedansht2211">
717737
<img src="https://github.com/vedansht2211.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="vedansht2211" /><br />
@@ -730,8 +750,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
730750
<sub><b>@vedikabajaj05</b></sub>
731751
</a>
732752
</td>
733-
</tr>
734-
<tr>
735753
<td align="center" width="120">
736754
<a href="https://github.com/vivekCS007">
737755
<img src="https://github.com/vivekCS007.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="vivekCS007" /><br />
@@ -745,9 +763,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
745763
</a>
746764
</td>
747765
<td width="120"></td>
748-
<td width="120"></td>
749-
<td width="120"></td>
750-
<td width="120"></td>
751766
</tr>
752767
</table>
753768
<!-- CONTRIBUTORS_END -->

math/Simple-Calculator/Simple-Calculator.py

Lines changed: 64 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import math
22

3-
from matplotlib.pylab import angle
4-
53
class Calculator:
64
def __init__(self):
7-
pass
5+
self.history = []
86

97
def start_calculation(self):
108
print("--------Menu---------")
@@ -23,11 +21,13 @@ def start_calculation(self):
2321
print('13. Cotangent')
2422
print('14. Secant')
2523
print('15. Cosecant')
26-
print('16. Exit')
24+
print('16. View History')
25+
print('17. Exit')
2726

2827
while True:
2928
try:
30-
user_input = int(input('Enter your choice to calculate(1-16): '))
29+
user_input = int(input('Enter your choice to calculate(1-17): '))
30+
3131
if user_input == 1:
3232
self.addition()
3333
elif user_input == 2:
@@ -59,13 +59,15 @@ def start_calculation(self):
5959
elif user_input == 15:
6060
self.cosecant()
6161
elif user_input == 16:
62+
self.show_history()
63+
elif user_input == 17:
6264
print('Goodbye! Have a good day.')
6365
break
6466
else:
6567
print('Wrong Choice.')
6668

6769
except ValueError:
68-
print('please enter correct option.')
70+
print('Please enter correct option.')
6971
except ZeroDivisionError:
7072
print('Zero cannot be divided by zero.')
7173
except Exception as e:
@@ -76,108 +78,137 @@ def clean(self, x, eps=1e-10):
7678
return 0.0
7779
return x
7880

81+
def add_history(self, operation):
82+
self.history.append(operation)
83+
84+
def show_history(self):
85+
if not self.history:
86+
print("No calculations yet.")
87+
else:
88+
print("\n------ Calculation History ------")
89+
for item in self.history:
90+
print(item)
7991

8092
def addition(self):
81-
a = int(input('enter first value: '))
82-
b = int(input('enter second value: '))
93+
a = float(input('Enter first value: '))
94+
b = float(input('Enter second value: '))
8395
add = a + b
8496
print(f'The Result is: {add}')
85-
97+
self.add_history(f"{a} + {b} = {add}")
98+
8699
def substraction(self):
87-
a = int(input('enter first value: '))
88-
b = int(input('enter second value: '))
100+
a = float(input('Enter first value: '))
101+
b = float(input('Enter second value: '))
89102
minus = a - b
90103
print(f'The Result is: {minus}')
104+
self.add_history(f"{a} - {b} = {minus}")
91105

92-
def division(self):
93-
a = int(input('enter first value: '))
94-
b = int(input('enter second value: '))
95-
div = a / b
96-
print(f'The Result is: {div}')
97-
98106
def multiplication(self):
99-
a = int(input('enter first value: '))
100-
b = int(input('enter second value: '))
107+
a = float(input('Enter first value: '))
108+
b = float(input('Enter second value: '))
101109
multiplication = a * b
102110
print(f'The Result is: {multiplication}')
111+
self.add_history(f"{a} * {b} = {multiplication}")
112+
113+
def division(self):
114+
a = float(input('Enter first value: '))
115+
b = float(input('Enter second value: '))
116+
div = a / b
117+
print(f'The Result is: {div}')
118+
self.add_history(f"{a} / {b} = {div}")
103119

104120
def floor_division(self):
105-
a = int(input('enter first value: '))
106-
b = int(input('enter second value: '))
121+
a = float(input('Enter first value: '))
122+
b = float(input('Enter second value: '))
107123
floor = a // b
108124
print(f'The Result is: {floor}')
125+
self.add_history(f"{a} // {b} = {floor}")
109126

110127
def modulus(self):
111-
a = int(input('enter first value: '))
112-
b = int(input('enter second value: '))
128+
a = float(input('Enter first value: '))
129+
b = float(input('Enter second value: '))
113130
mod = a % b
114131
print(f'The Result is: {mod}')
132+
self.add_history(f"{a} % {b} = {mod}")
115133

116134
def power(self):
117-
a = int(input('enter first value: '))
118-
b = int(input('enter second value: '))
135+
a = float(input('Enter first value: '))
136+
b = float(input('Enter second value: '))
119137
power = a ** b
120138
print(f'The Result is: {power}')
139+
self.add_history(f"{a} ** {b} = {power}")
121140

122141
def factorial(self):
123142
a = int(input("Enter the number: "))
124143
fact = 1
125-
for i in range(1,a+1):
126-
fact = fact * i
144+
for i in range(1, a + 1):
145+
fact *= i
127146
print(f"Factorial is: {fact}")
128-
147+
self.add_history(f"{a}! = {fact}")
148+
129149
def sqrt(self):
130-
num = int(input("Enter the number: "))
150+
num = float(input("Enter the number: "))
131151
sqrt = num ** 0.5
132-
print(f"Square root of {num} : {sqrt}")
152+
print(f"Square root of {num}: {sqrt}")
153+
self.add_history(f"sqrt({num}) = {sqrt}")
133154

134155
def sine(self):
135156
angle = float(input("Enter the angle in degrees: "))
136157
rads = math.radians(angle)
137158
sin_val = self.clean(math.sin(rads))
138159
print(f"Sine of {angle} degrees is: {sin_val}")
160+
self.add_history(f"sin({angle}) = {sin_val}")
139161

140162
def cosine(self):
141163
angle = float(input("Enter the angle in degrees: "))
142164
rads = math.radians(angle)
143165
cos_val = self.clean(math.cos(rads))
144166
print(f"Cosine of {angle} degrees is: {cos_val}")
167+
self.add_history(f"cos({angle}) = {cos_val}")
145168

146169
def tangent(self):
147170
angle = float(input("Enter the angle in degrees: "))
148171
rads = math.radians(angle)
149172
tan_val = self.clean(math.tan(rads))
150173
print(f"Tangent of {angle} degrees is: {tan_val}")
174+
self.add_history(f"tan({angle}) = {tan_val}")
151175

152176
def cotangent(self):
153177
angle = float(input("Enter the angle in degrees: "))
154178
rads = math.radians(angle)
155179
tan_val = self.clean(math.tan(rads))
180+
156181
if tan_val != 0:
157182
cot_val = 1 / tan_val
158183
print(f"Cotangent of {angle} degrees is: {cot_val}")
184+
self.add_history(f"cot({angle}) = {cot_val}")
159185
else:
160-
print(f"Cotangent of {angle} degrees is undefined.")
186+
print("Cotangent is undefined.")
161187

162188
def secant(self):
163189
angle = float(input("Enter the angle in degrees: "))
164190
rads = math.radians(angle)
165191
cos_val = self.clean(math.cos(rads))
192+
166193
if cos_val != 0:
167194
sec_val = 1 / cos_val
168195
print(f"Secant of {angle} degrees is: {sec_val}")
196+
self.add_history(f"sec({angle}) = {sec_val}")
169197
else:
170-
print(f"Secant of {angle} degrees is undefined.")
198+
print("Secant is undefined.")
171199

172200
def cosecant(self):
173201
angle = float(input("Enter the angle in degrees: "))
174202
rads = math.radians(angle)
175203
sin_val = self.clean(math.sin(rads))
204+
176205
if sin_val != 0:
177206
csc_val = 1 / sin_val
178207
print(f"Cosecant of {angle} degrees is: {csc_val}")
208+
self.add_history(f"csc({angle}) = {csc_val}")
179209
else:
180-
print(f"Cosecant of {angle} degrees is undefined.")
210+
print("Cosecant is undefined.")
211+
181212

182213
cal = Calculator()
183214
cal.start_calculation()

0 commit comments

Comments
 (0)