1. if else simplest.py
if True: print("If true, this will print.") #this else: print("If false, this will print.") #not this if False: print("If true, this will print.") #not this else: print("If false, this will print.") #this
if (5 > 1): print("5 is greater than 1...") print("Program should branch this way. All is fine.") else: print("5 isn't greater than 1...") print("Something has gone wrong if you are seeing this.")
temperature = 5 #degrees if temperature < 15: print("Wear a jumper") else: print("Wear a tshirt")
passMark = 5 score = int(input("What was your score out of 10?")) if score >= passMark: print("You passed! Congratulations.") else: print("Better luck next time.")
aBoolean = True print("well that was true") if aBoolean else print("no it wasn't")