December 13, 2016

December 9, 2016

December 7, 2016

Please reload

if's - selection structures

December 15, 2016


The if structure explains the processing in the following: 


Input > Processing > Output


The traditional program flow.



if this then that





if this :

    Do that




if x < 9:

     print(“x is less than 9.”)


Making it useful


Ask about something you don’t know - user input:


age=input(“What is your age?”)


if age>=21:

    print(“Please drink responsibly.”);

    print(“If you’re drinking, don’t drive.”);

print(“Have a great day!”)


It’s not: “do this or do that” - we will cover those soon

It’s:  “do this or don’t do this”

But it’s best to say: “if this then do that”

which implies: “if not this, then don’t do that”




Share on Facebook
Share on Twitter
Please reload

Please reload

Recent Posts

© 2019