Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 2

85 bytes added, 08:06, 26 May 2017
PART 1 - Using IF Statements
if True:
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 a if 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. In Python, Using indentation can control how will direct the program itself runs. From now on be very careful and consistent in the indetation that you make. Using indentation you can choose script what code runs will run as part of the if IF statement and what which code runs 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 onwards, be VERY careful and consistent in the indentation that you make with LOGIC statements.</li></ul><br><br>
:# However if the statement is False it will not run. Any code not indented under the if statement will perform normally.<source>
if False:
13,420
edits