Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 1.62 KB

File metadata and controls

54 lines (44 loc) · 1.62 KB

Lab 2.03 - Triangle Program

In your notebook

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

Example 1

    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 is thrown off bridge]")
        else:
            print("[You are thrown off the bridge]")

Example 2

    user_input = input("What is your favorite color"):
    if user_input == 'blue':
        print("Blue Skidoo")
    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...??")

Write a Triangle program

  • The program will ask for the lengths of all three sides of a triangle.
  • The program will display what kind of triangle it is or if it is a triangle.
  • The program will find the perimeter of the triangle.

Bonus

Research lists in Python. Re-implement Example 2 using lists.