CGSC 1005 Lecture Notes - Lecture 5: Boolean Expression
Document Summary
Iteration: repeated execution of one or more statements in a program. Assume there are only 4 expenses what"s the issue with the following code: It is very repeatitive, easier to use a loop. Statement is one or more lines of python code: note the indent before statement(s) It executes the statements inside the loop as long as the condition remains true. Changing values of the variables within the loop. When controlled by a variable, the loop must change that variable otherwise it will be endless loop. If condition is true, it executes each statement inside while block. If statement is false, it moves to code after while block. The goal of a while loop is to repeat the code inside of the block. We can control how many times the while code is executed by: the condition, by eventually making it evaluate to false, the break statement, or a combination of both.