Session 03 - Python for Forensics
The code here is to support the Session 03 lecture.
snakes.py
import random
def main():
print("You are in a realm full of snakes. You can see two large tree-houses in front")
print("of you at the top of two trees. In one tree, there are friendly snakes who will")
print("share some treasures, but in the other, there are pythons who will kill you.")
playAgain = "yes"
while playAgain.lower() == "yes":
chosenTree = input("Which tree will you go to? (1 or 2): ")
if chosenTree == "1" or chosenTree == "2":
print("You approach the tree...")
print("It is dark and spooky...")
snakeType = random.choice(["friendly", "python"])
if snakeType == "python":
print("A large snake jumps out at you! It hisses and opens its jaws...")
print("It wraps itself around you tightly and crushes your ribs. You are dead.")
else:
print("A large snake jumps out at you! It hisses and opens its jaws...")
print("It gives you some treasure!")
else:
print("Invalid choice. Please choose tree 1 or 2.")
playAgain = input("Do you want to play again? (yes or no): ")
if __name__ == "__main__":
main()