Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

rotate matrix 90 degrees clockwise python

#rotate 90 deg clockwise
box=[["a","b"],["c","d"],["e","f"]]

rows = len(box)
cols = len(box[0])

box2 = [[""] * rows for _ in range(cols)]

for x in range(rows):
    for y in range(cols):
        box2[y][rows - x - 1] = box[x][y]
Comment

rotate 90 degrees clockwise counter python

new_matrix = [[m[j][i] for j in range(len(m))] for i in range(len(m[0])-1,-1,-1)]
Comment

rotate matrix 90 degrees clockwise in python

#The program defines the square matrix 90 degrees clockwise direction.
m,n  = map(int,input().split())
#m,n are the number of rows and columns.
#m = int(input('rows'))
l = []
for i in range(m):
	x = list(map(int,input().split()))  #for taking the  rows a time and split it append to an empty list		
	l.append()
for i in range(m):
	for j in range(m-1,-1,-1):
		print(l[j][i],end=' ')
	print(end='
')
Comment

PREVIOUS NEXT
Code Example
Python :: import time in python 
Python :: enable debug mode flask 
Python :: make a window tkinter 
Python :: python get average of list 
Python :: list of numbers 
Python :: django cookies 
Python :: load img cv2 
Python :: delete values with condition in numpy 
Python :: how to append a number to a list in python 
Python :: delete nans in df python 
Python :: matplotlib overlapping labels 
Python :: python add up values in list 
Python :: groupby count pandas 
Python :: python file open 
Python :: python reversed range 
Python :: pyplot width 
Python :: python 2 deprecated 
Python :: append path to sys jupyter notebook 
Python :: python iterate through string in reverse 
Python :: TypeError: strptime() argument 1 must be str, not Series 
Python :: python dict append value 
Python :: python update multiple dictionary values 
Python :: drop every other column pandas 
Python :: changing plot background color in python 
Python :: how to rename rengeindex pandas 
Python :: conda environment 
Python :: get root path python 
Python :: discord.py how to print audit logs 
Python :: data series to datetime 
Python :: string formatting in python 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =