id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

sums


Write a function that takes as a parameter a two-dimensional grid (list of lists) H of numbers, and computes three lists. The first should contain the sum of each row of H. The second should contain the sum of each column of H, and the third should contain the sum of all the entries (so it has length 1). Define a list L to be the sum of these three lists in the order given above. Return this L.


sums([[1, 2, 3, 4], [0, 5, 2, 1], [3, 3, 2, 0], [0, 0, 4, 8]]) → [10, 8, 8, 12, 4, 10, 11, 13, 38]
sums([[-1, 6, 3, -4], [0, 0, 0, 0], [13, -3, 22, 10], [4, 9, -4, 5]]) → [4, 0, 42, 14, 16, 12, 21, 11, 60]
sums([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) → [0, 0, 0, 0, 0, 0, 0, 0, 0]

...Save, Compile, Run (ctrl-enter)

def sums(grid):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy