Home » Python Programming » Python Programming – Truth and While Loops

Python Programming – Truth and While Loops


 

Below is an example of a While Loop, where it is checking if the condition is met. If not, The count logic will increment up to 10, before breaking out of the loop.

This provides two possible methods to break out of the loop. There are times, when a loop is infinite.While you generally do not wish to have an infinite loop, there are times you purposely create one.

One example an infinite loop is needed may be an anti-virus software, that is monitoring the registration, files, for viruses. These are always running on your computer.

 

while_loop_ex

 

 

The Truth Terms
In Python we have the following terms (characters and phrases) for determining if something is “True” or “False.” Logic on a computer is all about seeing if some combination of these characters and some variables is True at that point in the program. These are used in our conditions, such as the use of != (not equal) in our While Loop example.

and
or
not
!= (not equal)
== (equal)
>= (greater-than-equal)
<= (less-than-equal)
True
False

 


Leave a comment

Your email address will not be published. Required fields are marked *