Odpowiedź:
Wyjaśnienie:
a) for x in array:
for y in x:
print(y,end = " ")
print()
b) array = [[1, 13, 9, 5], [15, 3, 12, 8]]
product = 1;
for x in array:
for y in x:
if (y>5):
product=product*y;
print(y,end = " ")
print()
print(product)
c)array = [[1, 13, 9, 5], [15, 3, 12, 8]]
product = 1;
differentFrom = 0;
for x in array:
for y in x:
if (y != 0):
differentFrom=differentFrom+1
if (y>5):
product=product*y;
print(y,end = " ")
print()
print(('Iloczyn liczb większych od 5 wynosi: {}').format(product))
print(('Ilość liczb, która jest różna od 0 wynosi {}').format(differentFrom))
d) array = [[1, 13, 20, 5], [15, 3, 12, 8]]
product = 1;
differentFrom = 0;
z = 0;
for x in array:
for y in x:
if(y >19):
z = z+1
if (y != 0):
differentFrom=differentFrom+1
if (y>5):
product=product*y;
print(y,end = " ")
print()
if (z > 0):
higherThanTwenty = 'istnieje'
else:
higherThanTwenty = 'nie istnieje'
print(('Iloczyn liczb większych od 5 wynosi: {}').format(product))
print(('Ilość liczb, która jest różna od 0 wynosi {}').format(differentFrom))
print(('Czy istnieje liczba nie mniejsza niż 20 - {}').format(higherThanTwenty))
Zadanie sprawdzone i pisane ręcznie