To understand everything that 61A is trying to teach you, it's important to understand the fundamental idea that everything is based on –– how are Python programs executed?

Direct Control Flow

In the simplest of functions, control simply flows downward.

a = 3
print(a) # prints 3

The reason this works is because the control goes up to down –– 3 is bound to a, and then looked up in line 2. This is quite like English, so we do it intuitively.

Breaking Control Flow With If

The first way you learn how to break control is through if. If is known as the "conditional", because one of many statements is conditionally executed.

if (3 > 4):
    print("suite 1") # this does not get executed
else:
    print("suite 2") # this gets executed

Try it out yourself in PythonTutor.

As you can see, the control arrow jumps from line 1 to line 3, skipping line 2 entirely. You could add anything to that line, and it won't error –– because it will never execute.

if (3 > 4):
    print(1/0) # should throw error but never executed
else:
    print("suite 2") # this gets executed

Breaking Control Flow With While

Another way we could change the flow of control is to make it go over the same block of code over and over again.

n = 1
while (n < 4):
    print("Hello") # prints thrice
    n = n + 1

The fundamental idea behind the loop is to do the same thing over and over again with small changes each time.

There are four parts to the loop –– the initial assignment (n = 1), the iterative condition (while n < 4), the execution (printing Hello) and the updation (n = n + 1). When we combine all four of these, we get a block of code that operates iteratively.

Breaking Flow Of Control With Functions

Another, more complicated way, the control flow is broken is through functions. Take this simple example.