Changes

Jump to: navigation, search

OPS435 Python Lab 2

25 bytes added, 07:10, 26 May 2017
PART 1 - Using IF Statements
print('This print is apart of the if statement')
</source>What happened? It is important to note a couple of things with the IF statement:<ul><li>When an '''IF statement is True''', it runs the code that is indented underneath it. In this case, we can use the boolean value "True" to make this happen, or test to see if a condition determined true or false.</li><li>Indentation means to start a line with spaces or tabs before your text. Using '''indentation''' will direct the script what code will run as part of the IF statement and which code will run as part of the main program. Also, using indentation makes it easier for a programmer to identify Control Flow statements. From this point on, be VERY careful and consistent in the indentation that you make with LOGIC statements. </li></ul><br>However, if the LOGIC statement is '''False''', then it will not run the code indented underneath it. Any code not indented under the if statement will perform normally as the main program and is NOT associated with control flow statement.
:#Issue the following 3 lines, indenting the second and third lines, but NOT the fourth line:<source>
if False:
print('This first print statement will never run')
13,420
edits

Navigation menu