Algoritm loyihalash fanidan 943-21 guruh talabasi Adamboyev sirojbek Pythonda ishlangan Amaliy ish №3 Mavzu


Download 200.8 Kb.
Sana18.06.2023
Hajmi200.8 Kb.
#1592897
Bog'liq
3- amaliy ish algortm loyihalsh fanidan adamboyev sirojbek


Algoritm loyihalash fanidan
943-21 guruh talabasi Adamboyev sirojbek
Pythonda ishlangan
Amaliy ish №3
Mavzu: Matritsa maksimal minimal elementini aniqlash algortimi. Matritsani ko’paytirish dasturi. Amallar tartibini baholash
Matritsani qatоr elеmеntlari yigindisidan vеktоr хоsil qilinsin, eng katta va engkichik elеmеnti aniqlansin.

matrix = [[-50, 53, 53, 54, 67, -8],


[41, -77, 57, -54, 43, -59],
[-94, 47, 36, 8, 92, -8],
[51, -5, 55, -57, 20, -34],
[-36, 71, 42, 18, 53, -80],
[69, -62, 16, -94, 64, -16]]

# Elementlarni yig'indisini hisoblash


sum_of_elements = sum(sum(matrix, [])) # sum() funksiyasi orqali yuqorida ko'rsatilgan usul bilan yig'indini hisoblaymiz

# Eng katta va eng kichik sonlarni izlash


largest = smallest = matrix[0][0] # birinchi elementni eng katta va eng kichik deb olib olamiz
for row in matrix:
for num in row:
if num > largest:
largest = num
elif num < smallest:
smallest = num

print("Elementlarning yig'indisi:", sum_of_elements)


print("Eng katta element:", largest)
print("Eng kichik element:", smallest)

Download 200.8 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling