3.9. Python types quiz

Assume the following variable assignments for the questions below:

kings = ['harold', 'alfred', 'william', 'lear', 'macbeth', 'kong']
orders = [dict(fritata = 3, french_toast=1),
          dict(ham_sandwich=1, eggs_over_sausage=1),
          dict(tiramisu=1,flan=1,chocolate_parfait=2)]
table2 = orders[2]
secret_word = 'facetious'
  1. Write down the values of the expressions below after the question marks. If an expression does not return a value , you should say None. If an expression will return an error, you should say so. You do not have to say what kind of error, but if you know, you can say so, and if there is an error, but you get the error type wrong, you still get full credit! The first one has been done as an example:

    * kings[2]::
    
         >>> 'william'
    
    * kings[5]::
    
         >>>
    
    * kings[-1]::
    
         >>>
    
    * kings[1][2]::
    
         >>>
    
    * orders[1]::
    
         >>>
    
    * orders[3]::
    
         >>>
    
    * kings[2:4]::
    
         >>>
    
    * table2['tiramisu']::
    
         >>>
    
    * table2[tiramisu]::
    
         >>>
    
    * orders[1]['eggs_over_sausage']::
    
         >>>
    
    * secret_word[1] = 'i'::
    
         >>>
    
  2. Write down expressions to retrieve the given values from the given variables.

  • dict(fritata = 3, french_toast=1) from orders:

    >>>
    
  • 2 from table2

    >>>
    
  • ‘ace’ from secret_word:

    >>>
    
  • ‘k’ from kings:

    >>>