Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+6 votes

Hi guys, I am having some trouble figuring out how to do the accumulation, can anyone help me out? Thanks

asked in CSC201 Spring 2021 by (8 points)

1 Answer

+3 votes

1) I think you mean Routine Practice 3, since RP4 hasn't been assigned yet!

2) This one is very similar to the example we did at the end of class, involving adding up the ODD squares, but in this case you want to add up ALL the squares. So, take a look at the range(...) function we used in class in order to get the odd numbers (1, 3, 5, ...), and think about how to change it so that you can get all the numbers starting at 1 (1, 2, 3, 4, ...)

answered by (8.3k points)

Ah! Thank you, I realized my line that was doing the accumulating was not indented and that's where my problem was.