111-20 guruh talabasi Xodjamberdiyev Dilshod
Python basics va oop fanidan
3-modulga qushimcha
Kodi:
matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]
# Birinchi uslub:
print("1. satr bo'yicha:")
for i in range(5):
for j in range(5):
print(matrix[i][j], end=" ")
print()
print("2. ustun bo'yicha:")
# Ikkinchi uslub:
for i in range(5):
for j in range(5):
print(matrix[j][i], end=" ")
print()
# Barcha elementlar ketma-ketligi
result = []
for i in range(5):
for j in range(5):
result.append(matrix[i][j])
print(result)
Natija:
Do'stlaringiz bilan baham: |