Ask Your Question
2

What method can be used to calculate the sum of each row using only for loops and if statements, excluding the use of sum function and numpy?

asked 2022-06-25 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-03-30 06:00:00 +0000

david gravatar image

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.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-25 11:00:00 +0000

Seen: 1 times

Last updated: Mar 30 '23