In short
A for loop repeats a block of code once for each item in a sequence, such as a list or a range of numbers.
for x in marks: takes each item of marks in turn and names it x. The code that is indented underneath runs once for each item. range(5) gives : it starts at and stops before . Use a for loop when you know how many times to repeat, and a while loop when you repeat until something happens.
This prints 15, which is .