Python Assignment_20230916_170922_0000
Python Assignment_20230916_170922_0000
Q1.
Input
A = [3,3,3,4,4,5,5,7,7,8,8,8,3,3,1,1,1,4,4,4,6,9]
Q2.
Input
A = [12,56,43,82]
B = [2,1,3,2]
[[49, 72, 28, 31, 10, 76, 45, 58, 22, 17],
[97, 47, 41, 63, 48, 65, 35, 23, 94, 90],
[47, 30, 79, 39, 13, 16, 1, 20, 49, 44],
[89, 78, 88, 36, 89, 15, 27, 30, 44, 83],
[ 6, 66, 47, 33, 46, 14, 16, 72, 4, 65],
[92, 32, 98, 98, 53, 6, 39, 74, 21, 46],
[47, 83, 86, 56, 98, 73, 46, 54, 82, 6],
[88, 91, 30, 16, 38, 5, 67, 48, 93, 69],
[86, 43, 32, 17, 96, 2, 38, 42, 61, 3],
[86, 88, 22, 14, 27, 80, 65, 93, 47, 25]]
IInd part:
Now, Check each element with its respective mean, i.e. First row elements
will be compared with b0 and second-row components will be compared
with b1, and so on.
If the element is greater than the mean value, then replace the element with 0
else leave it as it is.
Display the old matrix and the updated matrix.
IIIrd part:
Count the number of zeros and non-zero elements in the matrix and check if
the sum of both is equal to the total number of elements.
Python ASSIGNMENT
Q4:
A = [[49, 72, 28, 31, 10, 76, 45, 58, 22, 17],
[97, 47, 41, 63, 48, 65, 35, 23, 94, 90],
[47, 30, 79, 39, 13, 16, 1, 20, 49, 44],
[89, 78, 88, 36, 89, 15, 27, 30, 44, 83],
[ 6, 66, 47, 33, 46, 14, 16, 72, 4, 65],
[92, 32, 98, 98, 53, 6, 39, 74, 21, 46],
[47, 83, 86, 56, 98, 73, 46, 54, 82, 6],
[88, 91, 30, 16, 38, 5, 67, 48, 93, 69],
[86, 43, 32, 17, 96, 2, 38, 42, 61, 3],
[86, 88, 22, 14, 27, 80, 65, 93, 47, 25]]
Output
B = [[97,63,76,58,94],
[89,88,89,30,83],
[92,98,53,74,65],
[91,86,98,67,93],
[88,32,96,93,61]]
Now, you have to run a window of 2x2 over the 10x10 matrix and select
the maximum number out of each window and save it in a new matrix
which will have a size exactly equal to half of the previous original matrix.