Skip to content

Commit

Permalink
Rotates an Entered Matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartikeya006 committed Oct 20, 2020
1 parent c11eecd commit 6613934
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Python-programming-1/matrix_clock_rotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Rotate a Matrix by 90 degrees clockwise
import numpy as np
a = int(input("Enter Index of matrix:-"))
b = []
print("Enter the Matrix Element Rowwise:-")
for i in range(a):
c = []
for j in range(a):
c.append(int(input(f"Enter the {i+1}row {j+1}column Entry:-")))
b.append(c)


def print_matrix(z): # This function print the values of list in the list in form of Matrix
for i in range(len(z)):
for j in range(len(z)):
print(z[i][j], end=" ")
print()


print("Original Matrix is:-")
print_matrix(b)
degrees = {"90": 1, "180": 2, "270": 3}
c = np.rot90(b, 4-degrees["90"])
print("Matrix After Rotation(Clockwise):-")
print_matrix(c)

0 comments on commit 6613934

Please sign in to comment.