Saturday, May 3, 2014

Day 28

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Spent more time on the while function to repeat things while a particular condition is true.

The code I used:
mouse_alive = True
while mouse_alive:
print("You better set the trap!")
trap = input("Have we set the trap yet? ")
if trap == "yes":
mouse_alive = False
print("That mouse is toast!")

The interaction looked like this:
You better set the trap!
Have we set the trap yet? no
You better set the trap!
Have we set the trap yet? uh uh
You better set the trap!
Have we set the trap yet? yes
That mouse is toast!

No comments:

Post a Comment