2.1. Exercises
Name that Data Structure
Data Structure True and False
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.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.
The Data Structure Basics
Let’s explore how to add to a list, slice it and convert it into a tuple.
Tasks:
- Using the list provided, add a
pen, ascrap paper, a7.3and aTrueelement. - Find the length of the list after adding the element and save the value in an object named
drawer_length. - Slice the list from
4toscrap paperand save this in an object namedcleaned_junk_drawer. - Finally, convert it into a set and name it
junk_set.
Making a Dataframe from Lists
Let’s use lists and convert them into a pandas dataframe.
Tasks:
- Use the lists given in the cell below to make a dataframe.
- Name the dataframe
family.