Skip to content

Commit 79f6388

Browse files
authored
Merge branch 'main' into main
2 parents 9e17e29 + fab5a02 commit 79f6388

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

MatrixMultiplier.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
# taking a 3x3 matrix
4+
A = [[12, 7, 3],
5+
[4, 5, 6],
6+
[7, 8, 9]]
7+
8+
# take a 3x4 matrix
9+
B = [[5, 8, 1, 2],
10+
[6, 7, 3, 0],
11+
[4, 5, 9, 1]]
12+
13+
# result will be 3x4
14+
result = [[sum(a * b for a, b in zip(A_row, B_col))
15+
for B_col in zip(*B)]
16+
for A_row in A]
17+
#Now displaying the result
18+
for r in result:
19+
print(r)

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ Feel free to add basic python scripts/programs that helped you learn python. I h
3636
19. [Insertion Sort](https://github.com/musaibbatghar/Beginners-Python-Projects/blob/main/Insertion_Sort.py) - [Musaib Batghar](https://github.com/musaibbatghar)
3737
20. [Snake game](https://github.com/Aishanipach/Beginners-Python-Projects/compare/main...meanshkumar:Beginners-Python-Projects:main?expand=1)- [Ansh Kumar](https://github.com/meanshkumar)
3838
21. [Merge_Sort](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MergeSort.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
39+
3940
22. [Fibonacci_Series](https://github.com/Skillz619/Beginners-Python-Projects/blob/main/fibonacci_series.py) - [Shreekar Kolanu](https://github.com/Skillz619)
41+
42+
22. [Binary_Search](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/BinarySearch) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
43+
23. [TowerOfHoni](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/towerOfHoni.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
44+
24. [Matrix_Multiplier](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MatrixMultiplier.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
45+

snake_game.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from random import randrange
2+
from freegames import square,vector
3+
4+
food=vector(0,0)
5+
snake=[vector(10,0)]
6+
aim=vector(0,-10)
7+
8+
def change(x,y):
9+
aim.x=x
10+
aim.y=y
11+
12+
def inside(head):
13+
return -200 < head.x < 190 and -200 < head.y < 190
14+
15+
def move():
16+
head=snake[-1].copy()
17+
head.move(aim)
18+
if not inside(head) or head in snake:
19+
square(head.x,head.y,9,"red")
20+
update()
21+
return
22+
snake.append()
23+
24+
if head==food:
25+
print("snake",len(snake))
26+
food.x=randrange(-15,15)*10
27+
food.y=randrange(-15,15)*10
28+
else:
29+
snake.pop(0)
30+
clear()
31+
32+
for body in snake:
33+
square(body.x,body.y,9,"green")
34+
35+
square(food.x,food,y,9,"red")
36+
update()
37+
ontimer(move,100)
38+
39+
hideturtle()
40+
tracer(false)
41+
listen()
42+
onkey(lambda:changes(10,0),"Right")
43+
onkey(lambda:changes(-10,0),"Left")
44+
onkey(lambda:changes(0,10),"Up")
45+
onkey(lambda:changes(0,-10),"Down")
46+
47+
move()
48+
done()

towerOfHoni.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Recursive Code
2+
3+
def TowerOfHanoi(n , source, destination, auxiliary):
4+
if n==1:
5+
print ("Move disk 1 from source",source,"to destination",destination)
6+
return
7+
TowerOfHanoi(n-1, source, auxiliary, destination)
8+
print ("Move disk",n,"from source",source,"to destination",destination)
9+
TowerOfHanoi(n-1, auxiliary, destination, source)
10+
11+
#Test Input
12+
n = 4
13+
TowerOfHanoi(n,'A','B','C')
14+
# Consider A B and C as the names of rods
15+

0 commit comments

Comments
 (0)