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 :: python unicode point to utf8 string 
Python :: python print text 
Python :: what is self 
Python :: python create list 
Python :: aws s3 sync boto3 
Python :: // in python means 
Python :: python package install 
Python :: time conversion in python 
Python :: python eval 
Python :: django filter values with e and operator 
Python :: pop element from list python 
Python :: pytest use fixture without running any tests 
Python :: github downloader 
Python :: count function in python 
Python :: what is the ternary operator in python 
Python :: self.assertequal python 
Python :: ImportError: No module named pandas 
Python :: add python to path windows 10 
Python :: how to make a modulo in python 
Python :: bar break matplotlib 
Python :: create tab in python text 
Python :: python selenium class 
Python :: landscape odoo report 
Python :: arcpy line density 
Python :: csv utf-8 to iso-8859-1 python 
Python :: python quickly goto line in file 
Python :: mkvirtualenv 
Python :: 2d arrary.push in python 
Python :: pyglet template 
Python :: clipping path image using python 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =