Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One method to calculate the sum of each row using only for loops and if statements (excluding the use of sum function and numpy) is:

  1. Create an empty list to store the sums of each row
  2. Use a for loop to iterate through each row
  3. Initialize a variable to store the sum of the current row
  4. Use another for loop to iterate through each element in the current row
  5. Add each element to the sum variable
  6. Append the sum variable to the list of row sums
  7. Move on to the next row and repeat steps 3-6
  8. After iterating through all rows, the list of row sums should have the sum of each row.