Skip to content
beginner

Practice Exercises: Data Structures

Ready to build real Python skills? Practicing with Python data structures is one of the best ways to get comfortable with programming—and to prepare for…

Published 2026-05-11Updated 2026-05-157 min read

Ready to build real Python skills? Practicing with Python data structures is one of the best ways to get comfortable with programming—and to prepare for future jobs in tech. This article is packed with beginner-friendly exercises to help you master lists, dictionaries, tuples, and sets. Whether you’re brand new or brushing up, these hands-on challenges will help you learn Python by doing.


Why Practice Python Data Structures?

Data structures are the building blocks of Python programming. Lists, dictionaries, tuples, and sets help you organize, store, and work with data in your programs.

Diagram comparing Python lists, dictionaries, tuples, and sets, showing their main properties such as order, mutability, uniqueness, and key-value structure.

A visual comparison of Python's main data structures: lists, dictionaries, tuples, and sets. This helps you remember their differences and when to use each one.

Practicing these concepts is key to remembering and applying what you’ve learned. The more you use them, the more confident you’ll feel—whether you’re working on a personal project or interviewing for a programming job.

Each exercise is a step toward becoming a stronger, more capable Python programmer.


How to Use These Exercises

Here’s how to get the most out of these Python beginner exercises:

  • Try solving each exercise on your own first. Don’t peek at hints or solutions right away!
  • Use any Python editor or an online tool (like Replit or Python Tutor) to write and test your code.
  • Don’t worry about mistakes. Every error is a learning opportunity. Keep experimenting and tweaking your code until it works.

Ready? Let’s dive into some practical Python data structures exercises!


List Practice Exercises

Lists are one of the most flexible and commonly used data structures in Python. They let you store collections of items, like numbers or words.

1. Create and Print a List

  • Create a list called colors with the items: "red", "green", and "blue".
  • Print the list.

2. Add and Remove Items

  • Add "yellow" to the end of the colors list.
  • Remove "green" from the list.
  • Print the updated list.

3. Access and Change Items

  • Print the first item in the colors list.
  • Change the last item to "purple".
  • Print the list again.

4. Sort and Find Items

  • Create a list of numbers: [5, 2, 9, 1, 7].
  • Sort the list in ascending order and print it.
  • Check if the number 3 is in the list, and print the result (True or False).

5. Experiment with List Methods

  • Try using at least two different list methods (like .append(), .pop(), .insert(), or .reverse()) on any list you create.
  • Print the results to see how each method works.

Quiz Question 1

Question: What does the .append() method do for lists in Python?

  • A) It removes the last item from the list
  • B) It adds a new item to the end of the list
  • C) It sorts the list in place
  • D) It checks if an item is in the list

Dictionary Practice Exercises

Dictionaries store data in key-value pairs. They’re perfect for looking up information quickly and organizing related data.

1. Create and Print a Dictionary

  • Create a dictionary called person with keys: "name" (your name), "age" (your age), and "city" (your city).
  • Print the dictionary.

2. Update and Add Items

  • Change the "city" value to a different city.
  • Add a new key-value pair: "job" with any job title you like.
  • Print the updated dictionary.

3. Look Up and Remove Items

  • Print the value for the "name" key.
  • Remove the "age" key from the dictionary.
  • Print the dictionary again.

4. Use Dictionary Methods

  • Use the .keys() method to print all the keys in the dictionary.
  • Use the .values() method to print all the values.

Quiz Question 2

Question: How do you add a new key-value pair to a dictionary called my_dict?

  • A) my_dict.add('key', 'value')
  • B) my_dict['key'] = 'value'
  • C) my_dict.append('key', 'value')
  • D) my_dict.insert('key', 'value')

Tuples and Sets Practice Exercises

Tuples and sets are two more useful Python data structures. Tuples are like lists, but you can’t change them after they’re created (they are immutable). Sets are collections of unique items and are great for removing duplicates or checking membership.

1. Create and Use a Tuple

  • Create a tuple called dimensions with the values (10, 20, 30).
  • Print the second item in the tuple.

2. When to Use Tuples

  • Write a short comment in your code explaining why you might use a tuple instead of a list.

3. Create a Set and Remove Duplicates

  • Create a list with some repeated numbers: [1, 2, 2, 3, 4, 4, 5].
  • Convert the list to a set to remove duplicates.
  • Print the set.

4. Set Operations

  • Create two sets: a = {1, 2, 3} and b = {3, 4, 5}.
  • Print the union of the sets (all unique items from both).
  • Print the intersection (items both sets share).

Quiz Question 3

Question: Which Python data structure would you use if you want to store a collection of items that must all be unique?

  • A) List
  • B) Dictionary
  • C) Set
  • D) Tuple

Quiz Question 4

Question: What happens if you try to change an item in a tuple after it has been created?

  • A) You get an error because tuples cannot be changed
  • B) The item is updated successfully
  • C) A new tuple is automatically created
  • D) The item is removed from the tuple

Quick Review Quiz

Test your understanding with these short questions. Write your answers on paper or in your code editor.

Quiz Question 5

Question: How can you check if an item (for example, 5) is in a set called my_set?

  • A) my_set.has(5)
  • B) 5 in my_set
  • C) my_set.contains(5)
  • D) my_set.find(5)

Quiz Question 6

Question: Which data structure would you use to store the days of the week in order, where the order matters and you might want to change the values later?

  • A) Tuple
  • B) Set
  • C) List
  • D) Dictionary

Next Steps After Practicing

Great job working through these Python data structures exercises! Here’s how you can keep building your skills:

  • Try small projects. For example, make a contact book using dictionaries or a shopping list with lists.
  • Explore more advanced Python topics. Learn about loops, functions, and file handling.
  • Join coding communities. Sites like Stack Overflow, Reddit, or local groups can offer support, feedback, and new challenges.

Remember, the best way to learn Python is by doing. Keep practicing, stay curious, and celebrate your progress!

Ready for more? Check out our next article or explore more beginner exercises at learnpyfast.com. Your programming journey is just getting started!


Quiz Answer Key

Question 1

Correct answer: B) It adds a new item to the end of the list

Explanation: The .append() method adds a new item to the end of a list.


Question 2

Correct answer: B) my_dict['key'] = 'value'

Explanation: You add a new key-value pair to a dictionary by assigning a value to a new key using square brackets.


Question 3

Correct answer: C) Set

Explanation: Sets automatically remove duplicate items and only store unique values.


Question 4

Correct answer: A) You get an error because tuples cannot be changed

Explanation: Tuples are immutable, meaning their items cannot be changed after creation.


Question 5

Correct answer: B) 5 in my_set

Explanation: The in keyword checks if an item exists in a set.


Question 6

Correct answer: C) List

Explanation: Lists are ordered and mutable, making them perfect for storing items where order matters and changes may be needed.


Practical resource

Want a more structured Python path?

Use the Python Starter Pack to turn scattered tutorials into a focused practice path.

View the bundle
Coming soon

Python Starter Pack

A compact LearnPyFast PDF pack covering what Python is, installation, your first program, running Python code, and Python versions.

$9
PDF BundleTopic PackPythonBeginner
  • 5 curated chapters
  • Enhanced PDF edition with bundle-only learning guidance
  • Offline-friendly format for focused review
  • Source article links for future online updates

Coming soon

Related sites

Continue beyond Python

Explore related Worldmonger sites when you want to move from Python basics into JavaScript or LLM application building.

JavaScript tutorialstutorial

LearnJSFast

Beginner-friendly JavaScript tutorials for practical web development and self-taught developers.

JavaScriptFrontendWeb development
Visit LearnJSFast
LLM tutorialstutorial

LearnLLMFast

Practical LLM tutorials for builders who want to understand prompting, workflows, agents, and AI applications.

LLMAIBuilders
Visit LearnLLMFast

Keep learning

Related tutorials

Continue with nearby Python topics and beginner-friendly explanations.

beginner9 min read

Basic File I/O in Python

Learning to work with files is a practical and essential skill for any beginner Python programmer. Whether you want to save notes, read a list of tasks, or…

Read tutorial
beginner7 min read

Dictionaries in Python

Have you ever needed to match a name to a phone number, or a word to its definition? This idea of connecting one thing to another is everywhere in daily…

Read tutorial
beginner7 min read

Lists in Python

If you’ve ever made a grocery list, kept track of your favorite songs, or collected numbers for a project, you already understand the need to store…

Read tutorial