Changes

Jump to: navigation, search

OPS435 Python Lab 2

222 bytes added, 09:36, 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.:#Issue the following at the ipython3 shell:<source>a = 10b = 15if a > b: print('a is greater than b')else print('b is greater than a')</source>What happened?
:#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

Navigation menu