2nd Semester Intro to Computer Science

Lab 2.03 - Game Show

In your Notebook

Follow the flow of execution in the following programs and predict what will happen for each one

Example 1

  1. Follow the flow of execution in the following programs and predict what will happen for each one:

Example 2

    a = input("What... is your quest")
    b = "to seek the holy grail"
    if a != b:
        print("Go On. Off you go")
    else:
        b = input("What...is the air-speed velocity of an unladen swallow?")
        if b == "What do you mean? An African or European swallow?":
            print("I don't know that...AHHH [Bridgekeeper was thrown over bridge]")
        else:
            print("[you were thrown over bridge]")

Example 3

    user_input = input("What is your favorite color"):
    if user_input == 'blue':
        print("Blueskadoo")
    elif user_input == "red":
        print("Roses are red!")
    elif user_input == "yellow":
        print("Mellow Yellow")
    elif user_input == "green":
        print("Green Machine")
    elif user_input == "orange":
        print("Orange you glad I didn't say banana.")
    elif user_input == "black":
        print("I see a red door and I want it painted black")
    elif user_input == "purple":
        print("And we'll never be royalllssss")
    elif user_input == "pink":
        print("Pinky- and the Brain")
    else:
        print("I don't recognize that color. Is it even...??")

In your Console

Translate this Snap! program into a Python program

triangle_program

Create a game show program

  • Declare 10 prizes (prize1, prize2, prize 3 at the top of your file)
  • User picks a number
  • The prize corresponding with that door is printed for the user.

Bonus

Research lists in Python. Re-implement problem 3 using lists.

Edit this page Report an issue