Assignment 1 - Problem 3

Can anyone explain this? I really confused.

The first one i copied from other people, and the rest i wrote them myself

What do you want explained?

For loops, if statement?

What the condition is doing?

Or is there some part you want explained?

Why my 2nd, 3rd, and 4th coding have different print than the correct one (1st), even though it is the same coding. I’m trying to wrote it back but got different result. I’m so confused.

Maybe because you are using condition with i

for i in range(18,354):

But updating, your sum_of_numbers with 1 instead of i.

# In cases 2nd, 3rd, and 4th you are doing
sum_of_numbers += 1

# In 1st case it is 
# sum_of_numbers += i

So, in your code every time i%7 == 0 is satisfied it updates sum_of_numbers with 1 instead of i, which is what happens in the 1st case.

Thank you so much for your help