Skip to content

Commit 36e292e

Browse files
definehumandefinehuman
authored andcommitted
created and pushed
1 parent ea0f037 commit 36e292e

File tree

12 files changed

+294
-0
lines changed

12 files changed

+294
-0
lines changed

Generators/QuestionGenerator.py

100644100755
File mode changed.

Generators/cubegenerator.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
def cube_numbers(start, end):
4+
for i in range(start, end + 1):
5+
print(f"{i**3}")
6+
7+
if __name__ == "__main__":
8+
start = int(input("Enter the start number: "))
9+
end = int(input("Enter the end number: "))
10+
cube_numbers(start, end)
11+
12+
13+
14+
15+

Generators/diffencalc.py

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
def generate_table(number):
4+
print(f"Multiplication table for {number}:\n")
5+
for i in range(1, 21):
6+
result = number * i
7+
print(f"{number} x {i} = {result}, {convert_to_hindi(result)}")
8+
9+
def convert_to_hindi(number):
10+
hindi_numbers = {
11+
0: "शून्य", 1: "एक", 2: "दो", 3: "तीन", 4: "चार", 5: "पाँच", 6: "छह", 7: "सात",
12+
8: "आठ", 9: "नौ", 10: "दस", 11: "ग्यारह", 12: "बारह", 13: "तेरह", 14: "चौदह",
13+
15: "पंद्रह", 16: "सोलह", 17: "सत्रह", 18: "अठारह", 19: "उन्नीस", 20: "बीस"
14+
}
15+
return hindi_numbers.get(number, str(number))
16+
17+
if __name__ == "__main__":
18+
try:
19+
number = int(input("Enter a number between 2 to 20: "))
20+
if number < 2 or number > 20:
21+
raise ValueError("Number must be between 2 to 20")
22+
23+
generate_table(number)
24+
except ValueError as ve:
25+
print("Error:", ve)
26+
27+
28+
29+
30+
31+
32+

Generators/inversegenerator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
4+
5+
def print_inverses():
6+
for i in range(2, 21):
7+
for j in range(1, 21):
8+
inverse = round(1 / (j * i), 2)
9+
print(f"{inverse:<8}", end="")
10+
print()
11+
12+
if __name__ == "__main__":
13+
print_inverses()
14+
15+
16+
17+
18+

Generators/multiplicationtable.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
4+
5+
def print_multiplication_table(number):
6+
for i in range(1, 21):
7+
result = number * i
8+
print(result)
9+
10+
if __name__ == "__main__":
11+
try:
12+
number = int(input("Enter a number: "))
13+
print_multiplication_table(number)
14+
except ValueError:
15+
print("Please enter a valid number.")
16+
17+
18+
19+

Generators/sqgenerator.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
def square_numbers(lower, upper):
3+
squares = {}
4+
for num in range(lower, upper + 1):
5+
squares[num] = num ** 2
6+
return squares
7+
8+
if __name__ == "__main__":
9+
try:
10+
lower = int(input("Enter the lower number: "))
11+
upper = int(input("Enter the upper number: "))
12+
13+
if lower > upper:
14+
raise ValueError("Lower number cannot be greater than upper number")
15+
16+
result = square_numbers(lower, upper)
17+
18+
print("Squares of the numbers:")
19+
for num, square in result.items():
20+
print(f"{square}")
21+
except ValueError as ve:
22+
print("Error:", ve)
23+
24+
25+

SeperateProjects/PomodoroTimer/pomodorotimer.py

100644100755
File mode changed.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import matplotlib.pyplot as plt
2+
3+
def get_points():
4+
points = []
5+
print("Enter points as x,y pairs. Type 'done' to finish.")
6+
while True:
7+
user_input = input("Enter point (x,y): ")
8+
if user_input.lower() == 'done':
9+
break
10+
try:
11+
x, y = map(float, user_input.split(','))
12+
points.append((x, y))
13+
except ValueError:
14+
print("Invalid input. Please enter the point as x,y.")
15+
return points
16+
17+
def plot_points(points):
18+
x_vals = [point[0] for point in points]
19+
y_vals = [point[1] for point in points]
20+
21+
plt.scatter(x_vals, y_vals)
22+
plt.title('Plot of Points')
23+
plt.xlabel('X-axis')
24+
plt.ylabel('Y-axis')
25+
plt.grid(True)
26+
plt.show()
27+
28+
def main():
29+
points = get_points()
30+
if points:
31+
plot_points(points)
32+
else:
33+
print("No points to plot.")
34+
35+
if __name__ == "__main__":
36+
main()
37+
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
'''
2+
this is a more advanced program for grapher that can also map trignometric and quadratic inputs
3+
created: 14:03:23 6 July 2024
4+
Author: github.com/ChefYeshpal
5+
6+
to do:
7+
1. trig waves with values can also be generated
8+
2. multiple trig waves can be generated in one graph
9+
3. more than 2 degree quadratic eq's can be solved
10+
11+
'''
12+
13+
import matplotlib.pyplot as plt
14+
import numpy as np
15+
16+
17+
#for points
18+
def plot_points():
19+
points = []
20+
print("Enter points as x,y pairs. Type 'done' to finish.")
21+
while True:
22+
user_input = input("Enter point (x,y): ")
23+
if user_input.lower() == 'done':
24+
break
25+
try:
26+
x, y = map(float, user_input.split(','))
27+
points.append((x, y))
28+
except ValueError:
29+
print("Invalid input. Please enter the point as x,y.")
30+
31+
if points:
32+
x_vals = [point[0] for point in points]
33+
y_vals = [point[1] for point in points]
34+
plt.scatter(x_vals, y_vals)
35+
plt.title('Plot of Points')
36+
plt.xlabel('X-axis')
37+
plt.ylabel('Y-axis')
38+
plt.grid(True)
39+
plt.show()
40+
else:
41+
print("No points to plot.")
42+
43+
44+
#for trignometric functions
45+
def plot_trig_function():
46+
functions = {
47+
'sin': np.sin,
48+
'cos': np.cos,
49+
'tan': np.tan,
50+
'csc': lambda x: 1/np.sin(x),
51+
'sec': lambda x: 1/np.cos(x),
52+
'cot': lambda x: 1/np.tan(x)
53+
}
54+
55+
print("Choose a trigonometric function to plot (sin, cos, tan, csc, sec, cot):")
56+
func = input().lower()
57+
if func in functions:
58+
x = np.linspace(-2*np.pi, 2*np.pi, 1000)
59+
y = functions[func](x)
60+
plt.plot(x, y, label=func)
61+
plt.title(f'Plot of {func}(x)')
62+
plt.xlabel('X-axis')
63+
plt.ylabel(f'{func}(x)')
64+
plt.axhline(0, color='black',linewidth=0.5)
65+
plt.axvline(0, color='black',linewidth=0.5)
66+
plt.grid(True, which='both')
67+
plt.legend()
68+
plt.show()
69+
else:
70+
print("Invalid function. Please choose from sin, cos, tan, csc, sec, cot.")
71+
72+
73+
#for quadratic euations
74+
def plot_quadratic():
75+
print("Enter coefficients for the quadratic equation ax^2 + bx + c = 0:")
76+
try:
77+
a = float(input("Enter coefficient a: "))
78+
b = float(input("Enter coefficient b: "))
79+
c = float(input("Enter coefficient c: "))
80+
81+
x = np.linspace(-10, 10, 400)
82+
y = a * x**2 + b * x + c
83+
plt.plot(x, y, label=f'{a}x^2 + {b}x + {c}')
84+
plt.title('Plot of Quadratic Equation')
85+
plt.xlabel('X-axis')
86+
plt.ylabel('Y-axis')
87+
plt.axhline(0, color='black',linewidth=0.5)
88+
plt.axvline(0, color='black',linewidth=0.5)
89+
plt.grid(True, which='both')
90+
plt.legend()
91+
plt.show()
92+
except ValueError: #in case of space of nonvalue
93+
print("Invalid input. Please enter numerical values for coefficients.")
94+
95+
#options to graph
96+
def main():
97+
print("Choose the type of graph you want to plot:")
98+
print("1. Points")
99+
print("2. Trigonometric Function")
100+
print("3. Quadratic Equation")
101+
choice = input("Enter your choice (1/2/3): ")
102+
#loop
103+
if choice == '1':
104+
plot_points()
105+
elif choice == '2':
106+
plot_trig_function()
107+
elif choice == '3':
108+
plot_quadratic()
109+
else:
110+
print("Invalid choice. Please enter 1, 2, or 3.")
111+
112+
if __name__ == "__main__":
113+
main()
114+

0 commit comments

Comments
 (0)