NPTEL PROGRAMMING ASSIGNMENTS
The Joy of Computing Using Python
Weekk 7 Programming Assignment 1
Last Day of Submission: 16-Mar-2023
Given a sqaure matrix M, write a function DiagCalc that calculates the sum of left and right diagonals and prints it respectively.
Input Formate:
Integer, List
Output Formate:
Integer, Integer
Input:
3
1 2 3
4 5 6
1 2 3
4 5 6
7 8 9
Output:
15
15
15
Week 7 Programming Assignment 2
Last Day of Submission: 16-Mar-2022
Given a matrix M write a function Transpose which accepts a matrix M and return the transpose of M.
Input Formate:
Integer, List(Matrix)
Output Formate:
Transpose Matrix
Input
Output
Input
2
1 2
3 4
1 2
3 4
Output
1 3
2 4
2 4
n = int(input())
M = []
for i in range(n):
M = []
for i in range(n):
L = list(map(int, input().split()))
M.append(L)
M.append(L)
print(Transpose(M))
Week 7 Programming Assignment 3
Last Day of Submission: 16-Mar-2022
Given a matrix M write a function snake that accepts a matrix M and returns a list which contain elements in snake pattern of matrix M.
Input Formate:
Integer, List(Matrix)
Output Formate:
Snake List
Input
Input
2
1 2
3 4
1 2
3 4
Output
[1, 2, 4, 3]
[1, 2, 4, 3]
n = int(input())
M = []
for i in range(n):
L = list(map(int, input().split()))
M.append(L)
print(snake(M))