An Introduction to Python For Undergraduate Engineers/Boolean Logic

From Wikibooks, open books for an open world
Jump to navigation Jump to search

You can use simple Boolean expressions in logical statements such as those that we used in the while loop. The available expressions are:

Expression Example Description of example
and while done==False and x<10: keep looping whilst both done equals false and x is less than 10
or if count==10 or value==5: do something if variable count=10 or the variable value=5
not while not done: keep looping while the done variable is not 'True'