External Exam Download Resources Web Applications Games Recycle Bin

Branching AND OR NOT

and.py

roomClean = False
homeworkDone = True

if roomClean and homeworkDone:
  print("You can go out to play.")
else:
  print("You haven't finished your chores.")


or.py

position = 1 #1st place!
time = 10.22
personalBest = 9.87

if position == 1 or time < personalBest:
  print("Great run!")
else:
  print("Never mind")



not.py

feeling = "happy"

if not(feeling == "happy"):
  print("Cheer up brussel sprout!")
else:
  print("That's great, keep smiling!")



complex logic.py

foul = False
speed = 220.4 #220.4 km/hr
outcome = "returned"

if not(foul) and (speed >= 200.0 or outcome == "Ace"):
  print("Great serve!")



  1. to craft a stone pickaxe in Minecraft i need 3 cobblestones and 2 sticks. Create two variables to store the number of cobblestones and sticks i have. If i have enough of both, say "pickaxe crafted". If i dont, say "not enough resources". You may need a more complex boolean expression to check both variables at once, e.g.: if cobblestones >= 3 and sticks >= 2:

  2. to craft an axe (aka hatchet) in Minecraft i can use 2 sticks plus either 3 cobblestones or 3 wood planks. complete the same task as the previous question, however this time say "axe crafted" instead of "pickaxe crafted".


  3. create three variables raincoats, umbrellas and puddles. Set each of these variables to a random number between 1 and 6. If i have more raincoats and umbrellas combined than puddles, print "staying dry".