Python Data Structure Exercises

Let’s check out some exercises that will help you understand structured data types in Python better, also usually referred to as composite data types as well.

Exercise 5-a

Let's create an empty list and print its type.


list() is a function that creates an empty list. You don’t need to put anything inside list() function to achieve this. The same thing can be achieved by typing brackets: []

type() function will tell you the class type of your variable.

gift_list = []
answer_1 = type(gift_list)

Exercise 5-b

Now, we will create an empty dictionary and print its type.


dict() is a function that creates an empty list. You don’t need to put anything inside dict() function to achieve this.

The same thing can be achieved by typing curly brackets: {}

type() function will tell you the class type of your variable.

grocery_items = {}
answer_2 = type(grocery_items)

Now let’s see some more exercises about converting data types.