In-Class Questions and Video Solutions

Lecture 2

  1. Strings

    What is the value of variable `u` from the code below?

    once = "umbr"

     umbrella ella ella ella  check
     umbrellaellaellaella  close
     umbrella  close
     umbrella4  close

  2. Comparisons

    What does the code below print?

    pset_time = 15

     False then False  check
     False then True  close
     True then False  close
     True then True  close
    Check Show Solution

  3. Branching

    What’s printed when x = 0 and y = 5?

    x = float(input("Enter a number for x: "))

     x is smaller  check
     y is smaller  close
     x / y is 0.0  close
    Check Show Solution

  4. While Loops

    In the code below from Lecture 2, what is printed when you type “Right”?

    n = input("You're in the Lost Forest. Go left or right? ")

     You're in the Lost Forest. Go left or right?  close
     You got out of the Lost Forest!  check
    Check Show Solution

  5. For Loops

    What is printed when the below code is run?

    mysum = 0

     5  check
     6  close
     21  close
     24  close
    Check Show Solution

Course Info

Learning Resource Types

assignment Problem Sets
notes Lecture Notes
theaters Lecture Videos
assignment_turned_in Programming Assignments with Examples