Programs That Can Loop
Learn how to execute a block of code multiple times.
We'll cover the following
We’ve found a way to break the strictly sequential flow of a program by pushing one or however many statements within an if
block. This means that our lines of code, other than those in if
-else
blocks, will get executed line by line, in sequence. But some lines of code will only get executed if a condition is True
, otherwise, another set of lines will become a part of the execution. Sequential or selective, each line of code only gets executed once, and then our computer fetches the next one, and then the next.
The while
loop
Wouldn’t it be great for programmers if they could make the computer execute a block of code repeatedly while a condition is True
?
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy