15.10. Mixed-Up Code Questions

Put the code blocks in order to import the json library. Then convert the string <code>x</code> to a Python dictionary. Then print the value for the <code>”age”</code> key.

Put the blocks in order to output a Python dictionary <code>x</code> as a JSON string. Watch out for an extra piece of code!

Put the blocks in order to import the needed module, define the data, read an XML tree from the data, and print the name and email hide attribute value.

Put the blocks in order to define a JSON encoding that is roughly equivalent to the simple XML from before. It first includes the name and phone number, then the email (which isn’t visible). Drag the blocks of statements from the left column to the right column and put them in the right order. Watch your indentation!

Put the blocks in order to convert JSON data for Chuck and Brent to Python then print the number of entries and their data, but the code is mixed up. Drag the blocks of statements from the left column to the right column and put them in the right order. Watch out for three extra pieces of code and indentation!

Put the blocks in order to define the XML for a note. First the recipient is listed, then the sender, heading, and message. There is an extra block that isn’t needed in a correct solution.

Put the blocks in order to create a restaurant’s menu that lists breakfast items, their price, description, and calorie count. These 3 items should be listed in the order of: Belgian Waffles, French Toast, Homestyle Breakfast.

Put the blocks in order to convert a python dictionary to JSON, then use the sort_keys parameter to specify if the result should be sorted or not. Watch your indentation and make sure closing brackets/braces are in the right order!

You have attempted of activities on this page