In-Class Questions and Video Solutions

Lecture 5

  1. Tuples

    Examine the code below. What does always_sunny(('cloudy'), ('cold',)) evaluate to?

    def always_sunny(t1, t2):
    

     ('sunny', 'cc')  close
     ('sunny', 'ccold')  check
     ('sunny', 'cloudycold')  close
    Check Show Solution

  2. Simple Lists

    What is the value of L after you run the code below?

    L = ["life", "answer", 42, 0]
    

     \["life", "answer", 42, 0\]  close
     \["universe", "answer", 42, 0\]  close
     \["universe", "everything", 42, 0\]  check
     \["life", "everything", 42, 0\]  close
    Check Show Solution

  3. List Operations

    What is the value of L3 after you execute all the operations in the code below?

    L1 = ['re']
    

     \['mi', 're', \['fa', 'la'\]\]  check
     \['mi', 're', 'fa', 'la'\]  close
     \['re', 'mi', \['fa', 'la'\]\]  close
     \['do', 'mi', \['fa', 'la'\]\]  close
    Check Show Solution

  4. List Aliasing/Mutation

    What is the value of brunch after you execute all the operations in the code below?

    L1 = ["bacon", "eggs"]
    

     \['bacon', 'eggs', 'toast', 'jam'\]  close
     \['bacon', 'eggs', 'juice', 'toast', 'jam'\]  check
     \['bacon', 'eggs', 'juice', \['toast', 'jam'\]\]  close
     \['bacon', 'eggs', \['toast', 'jam'\]\]  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