Advertisement
VladimirKostovsky

весь путон за 42 секунды

May 16th, 2022
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import random
  2.  
  3. matrix = [[random.randint(-10, 10) for x in range(3)] for x in range(10)]
  4. print('Исходная матрица:', matrix)
  5. s = []
  6. for i in range(len(matrix)):
  7.     s.append(sum(matrix[i]))
  8. print("Строка с наибольшей суммой:", matrix[s.index(max(s))], "Сумма элементов:", max(s),
  9.       "\n Строка с наименьшей суммой:", matrix[s.index(min(s))], "Сумма элементов:", min(s))
  10.  
  11. matrix = [[1 if x > 0 else 0 for x in i] for i in matrix]
  12. for i in range(len(matrix)):
  13.     print(*[matrix[i][x] if x <= i else '' for x in range(len(matrix[i]))], '')
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement