Q:

Python program to filter matrix based on a condition

belongs to collection: Python Array Programs

0

Matrix in python is a two-dimensional data structure which is an array of arrays.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to filter matrix based on a condition

T=(("Ajay",90),("Peter",45),("Jack",80))

print("All students : ", T)

R=()

for t in T:
    if(t[1]>=70):
        R+=(t,)

print("Students with score more than 70 : " , R)

Output:

All students :  (('Ajay', 90), ('Peter', 45), ('Jack', 80))
Students with score more than 70 is  (('Ajay', 90), ('Jack', 80))

In the above code, we have created the matrix T, with student name and marks. And then printed the value. The filter is using the greater than sign and store to an array. Then print this matrix.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python program to illustrate the working of lambda... >>
<< Python program to add two matrices and print the r...