3.1. Exercises
Dictionary Questions
Coding questions
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Dictionary Basics
Recently Jeremy bought a new Ikea shoe rack. The packaging included quite a few parts and he is finding it hard to keep track!
Tasks:
- Make a dictionary that includes the quantity of each part included in the Ikea set.
The shoe rack contained the following parts:
8
Long Screw8
Wood Dowel2
Short Screw1
Allen KeyConstruct the dictionary so that the part names are the keys and the quantities of the parts, are the values for the dictionary.
Name the dictionary
ikea_shoe_rack.
Building a Dataframe from a Dictionary
The shoe rack was not the only thing Jeremy bought. below is a table of all his purchases.
| item_name | collection | price | |
|---|---|---|---|
| 0 | Bistro Set | APPLARO | 216.98 |
| 1 | Shelf Unit | HYLLIS | 11.99 |
| 3 | Shoe Rack | TJUSIG | 29.99 |
Tasks:
- Create the table above from a dictionary using
pd.DataFrame.from_dict(). - Name your new dataframe ikea_df