snow = [
[0, 2, 5, 0, 0, 12, 3], # week 1, Monday to Sunday (cm)
[1, 0, 0, 8, 4, 0, 0], # week 2
[15, 6, 0, 0, 2, 0, 1], # week 3
[0, 0, 3, 3, 0, 9, 20], # week 4
]
rows = len(snow)
cols = len(snow[0])
# row totals: one per week
for r in range(rows):
total = 0
for c in range(cols):
total += snow[r][c]
print("Week", r + 1, "total:", total, "cm")
# column totals: one per day of the week
days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
col_totals = [0] * cols
for r in range(rows):
for c in range(cols):
col_totals[c] += snow[r][c]
print(days)
print(col_totals)
# the snowiest day and where it is
best_r, best_c = 0, 0
for r in range(rows):
for c in range(cols):
if snow[r][c] > snow[best_r][best_c]:
best_r, best_c = r, c
print("Most snow:", snow[best_r][best_c], "cm in week", best_r + 1, "on", days[best_c])