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 secret_word = 'facetious'
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:: >>> 'william' * kings:: >>> * kings[-1]:: >>> * kings:: >>> * orders:: >>> * orders:: >>> * kings[2:4]:: >>> * table2['tiramisu']:: >>> * table2[tiramisu]:: >>> * orders['eggs_over_sausage']:: >>> * secret_word = 'i':: >>>
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:>>>