Skip to content

Latest commit

 

History

History
69 lines (46 loc) · 1.76 KB

File metadata and controls

69 lines (46 loc) · 1.76 KB

Lab 2.02 - Can I or Can't I?

In your notebook

Predict if each of the following examples will produce a True or False output. Check your answers in interactive mode.

Example 1

    a = 100
    b = "science"
    a > 75 and b == "science"

Example 2

    a = 100
    b = "science"
    a > 75 and b != "science"

Example 3

    a = 100
    b = "science"
    a > 75 or b != "science"

Example 4

    a = 100
    b = "science"
    c = True
    not c and a > 75 and b == "science"

In your console

Complete the following coding challenge

  1. Create a "Can I be President?" program, which determines if the user meets the minimum requirements for becoming the President of the United States. Have the user input the information needed.

    The minimum requirements to be president of the United States are:

    • Older than 35
    • Resident of US for 14 Years
    • Natural born citizen

    Print True if the person could be president and False if they can't be president.

  2. Create a "Can I ride the roller coaster?" program. It will check to see if the user meets the minimum requirements to ride the roller coaster. Have the user input the information needed.

    Requirements to ride the roller coaster:

    • Height over 50 inches – loophole allows any height if older than 18
    • Each ride costs 4 quarters.
    • There is a frequent rider pass, which makes the rides only cost 2 quarters.

    Print True if the user can ride the roller coaster, and False if not.

Bonus

Are the following expressions equivalent? Research DeMorgan's Laws and write why you think they are the same or why they are not the same

not(x or y) == not x and not y

not(x and y) == not x or not y