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 os get output 
Python :: python date 
Python :: nodemon python 
Python :: python roll dice 100 times 
Python :: python find the factors of a number 
Python :: python first two numbers 
Python :: numpy isinstance 
Python :: normalize column pandas 
Python :: matplotlib latex non italic indices 
Python :: make tkinter button disable 
Python :: python method to filter vowels in a string 
Python :: python read dictionary from file 
Python :: convert int to byte python 
Python :: django secret key 
Python :: django return only part of string 
Python :: how to read a json resposnse from a link in python 
Python :: python legend being cut off 
Python :: python convert list to dict with index 
Python :: crear matriz python for 
Python :: wait for input python 
Python :: python tkinter listbox click event 
Python :: how to get pygame window height size 
Python :: binary to text python 
Python :: serving static audio files with flask in react 
Python :: cool advances python ptoject ideas 
Python :: py to exe converter online 
Python :: Embed picture in email using smtplib 
Python :: make python file executable linux 
Python :: print('Test set predictions: {}'.format(y_pred)) 
Python :: minimum from list of tuples 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =