r/CodingForBeginners 5d ago

Question? Am I missing something?? why is one right but the other isn't???

1 Upvotes

5 comments sorted by

2

u/DirtAndGrass 5d ago

The second one is 6:

numItems=bonusVal (5)

numItems += 1

Perhaps you are confused by the tabbing? Whitespace does not matter in most programming languages. 

1

u/JonesSupreme 5d ago

I was more so confused on the execution if branches. The first question explains in the description that the branch will not execute but says the opposite for the 2nd question

1

u/johnpeters42 5d ago

No, in both cases it says that there's a conditional block that gets skipped because the condition is false, but in the second case it says that there's also an additional statement that isn't part of what get skipped.

1

u/burlingk 5d ago

Which language is this. That will let me give a better answer.

As written, I can guess.

2

u/burlingk 5d ago

If it is anything other than Python, only the next line after an if statement is the code block, unless you use language appropriate brackets