A while loop is a pre-test loop that executes its body of code repeatedly while the loop's expression evaluates to true. Once the expression is false, the loop ends and your Python program continues with the next statement outside the loop.
An iteration is one execution of the loop body. A loop variable counts the number of loop iterations and is typically used to control the loop.
A sentinel value may optionally be used to control the end of the loop. This is helpful for interactive programs, where you ask the user to type q to quit.
You use loops everyday. For example, when you are eating a sandwich, you may look at it and ask yourself “Is there more sandwich?”, and “Am I still hungry?”. If both conditions are true, then you’d take another bite. If you weren’t hungry, you’d stop the eating loop. If you had no sandwich left, but were still hungry, then you’d have to stop the eating loop too, otherwise you’d bite your hand off.
Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!