Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 2

16 bytes added, 08:38, 26 May 2017
PART 2 - Using IF/ELIF/ELSE Statements
if a > b:
print('a is greater than b')
</source>What happened? Let's now use an IF/ELSE statement.<br><br>
:#Issue the following at the ipython3 shell:<source>
a = 10
else
print('b is greater than a')
</source>What happened?<br><br>
:#But we may want to know if 'a' is less than 'b'. The 'elif' statement allows us to string together multiple if statement. This new statement 'elif' means: IF the first condition is False, it will check the second condition under 'elif'. HOWEVER, if the first condition is True, it will run the code indented under the first condition and SKIP the 'elif' statement.<source>
a = 10
13,420
edits