Changes

Jump to: navigation, search

OPS435 Python Lab 2

136 bytes added, 09:58, 26 May 2017
PART 1 - Understanding WHILE Loops
print('loop has ended')
</source>A WHILE loop can also be used as an '''Indeterminant Loop'''. That term means that the number of loops are '''unknown''' in advance. For example, the loop keeps on repeating until the user enters the correct data - we have no idea how many times that user will do that, since that is the job of the user running the script and NOT the programmer. Indeterminant Loops are extremely useful for '''error-checking''' in order to prevent incorrect data being accepted and causing the script not to perform correctly.<br><br>
:#Here is an example of guessing an indeterminant loop for error-checking.<br> Issue the following at the ipython3 shell and type several incorrect passwords then the correct passwordone to see what happens:<source>
password = ''
while password != 'P@ssw0rd':
13,420
edits

Navigation menu