๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

defines a matrix

โ† All Python Programs

Aim:

☛   Write a python program that defines a matrix and prints.

Solution :


PROGRAM: (matrix_print.py)

 
R = int(input(" Enter the number of rows : "))
C = int(input(" Enter the number of columns : "))
# Initialize matrix
matrix = []
print(" Enter the entries row - wise : ")
# For user input
for i in range(R):
	a = []
	for j in range(C):
		a.append(int(input()))
	matrix.append(a)
print()

# For printing the matrix
print(" Matrix Values are: \n ")
for i in range(R) :
	for j in range(C):
		print(matrix[i][j] , end = " ")
	print()

OUTPUT:

 
 Enter the number of rows : 3
 Enter the number of columns : 3
 Enter the entries row - wise :
1
2
3
4
5
6
7
8
9

 Matrix Values are:

1 2 3
4 5 6
7 8 9


๐Ÿ’ป Run This Python Program

defines a matrix
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals