Question

Q2 Cancer Finder

25 Points

Purpose: Use a 2-d array in a simple science application.

Use for loops to generate a 20 by 30 matrix, initialized with random values between 0 and 9. Now,

write separate loops that print out the array. Now, assume that numbers 8 and over are "Bad",

and that numbers 2 and under are "Good"; you may think of these as levels of cancer expression

across an array of cells in a piece of tissue. Write separate loops that go through the stored array

and (i) print out the array of classification (use 'B' for "Bad", 'G' for "Good" and "for others) and (ii)

count the number of "Bad" and "Good" cells. Report these final counts.

Turn in: Name your notebook cancerFinder.ipynb. Comment your program. Cut and paste it in the

box below. Also, cut and paste just one example run of your program's output (random array,

classification array, plus final Good/Bad counts) in a separate text block.

Hint: To initialize a 2-D array to all zeros that is 5 by 7, you can use the following pattern for "list

comprehension":

array = [[0 for col in range (7)] for row in range (5)] # 5 rows, 7 cols

ALTERNATIVELY:

array []

for row in range (5):

array_row = []

for col in range (7):

array_row.append(0)

array.append(array_row)

Question image 1