Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- matrix = [
- [ 1, 2, 3, 4, 5 ], # 2 = matrix[0][1]
- [ 1, 2, 3, 4, 5 ], # 2 = matrix[1][1]
- [ 1, 2, 3, 4, 5 ], # 2 = matrix[2][1]
- [ 1, 2, 3, 4, 5 ], # 2 = matrix[3][1]
- [ 1, 2, 3, 4, 5 ], # 2 = matrix[4][1]
- ]
- sum = [ 5, 10, 15, 20, 25 ]
- def print_colum(matrix, col):
- for riga in range(0, len(matrix)):
- print(str(matrix[riga][col]) + " ", end="")
- def sum_col(matrix, col):
- sum = 0
- for riga in range(0, len(matrix)):
- sum = sum + matrix[riga][col]
- return sum
- def sum_all_col(matrix):
- sum_list = []
- for col in range(0, len(matrix[0])):
- sum_list.append(sum_col(matrix, col))
- return sum_list
- def filter_odd_columns(matrix):
- odd_colums = []
- all_colum_sum = sum_all_col(matrix)
- for index, column_sum in enumerate(all_colum_sum):
- if(column_sum % 2 != 0):
- odd_colums.append(index)
- return odd_colums
- def print_odd_columns(matrix):
- odd_colums = filter_odd_columns(matrix)
- for col in odd_colums:
- print_colum(matrix, col)
- print()
- print_odd_columns(matrix)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement