Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement function pixels() that takes as input two-D list of nonnegative intege

ID: 3547225 • Letter: I

Question

                            Implement function pixels() that takes as input two-D list of nonnegative integers entries(representing the values of pixels of an image) and returns                             the number of entries that are positive (ie the number of pixels that are not dark). you function should work on 2D lists of any size.                         

                            >>>x=[[0,156,0,0],[34,0,0,0],[23,123,0,34]]                         

                            >>>pixels(x)                         

                            5                         

                            >>>x=[[123,56,255],[34,0,0],[23,123,0],[3,0,0]]                         

                            >>>pixels(x)                         

                            7                         

Explanation / Answer

#x=[[0,156,0,0],[34,0,0,0],[23,123,0,34]]

def(pixels(list)):

count=0

for y in list:

for z in range(0,len(y)):

if y[z]>0:

count=count+1

print(count)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote