Python Basics Exercises: Lists and Tuples

Martin Breuss
Martin Breuss 37 Lessons 2h 26m basics python

In Python Basics: Lists and Tuples, you learned that Python lists resemble real-life lists in many ways. They serve as containers for organizing and storing collections of objects, allowing for the inclusion of different data types. You also learned about tuples, which are also collections of objects. However, while lists are mutable, tuples are immutable.

In this Python Basics Exercises course, you’ll test and reinforce your knowledge of Python lists and tuples. Along the way, you’ll also get experience with some good programming practices that will help you solve future challenges.

In this video course, you’ll practice:

  • Defining and manipulating lists and tuples in Python
  • Leveraging the unique qualities of lists and tuples
  • Determining when you should use lists vs tuples

By the end of this course, you’ll have an even stronger grasp of Python lists and tuples. You’ll be equipped with the knowledge to effectively incorporate them into your own programming projects.

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3. You can also check out the other Python Basics courses.

Note that you’ll be using IDLE to interact with Python throughout this course.

What’s Included:

Downloadable Resources:

Related Learning Paths:

About Martin Breuss

Martin is Real Python's Head of Content Strategy. With a background in education, he's worked as a coding mentor, code reviewer, curriculum developer, bootcamp instructor, and instructional designer.

» More about Martin

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

Avatar image for ajackson54

ajackson54

The Poem Generator was fantastic! I’m going to spend a few hours experimenting with this.

Avatar image for johnlukow

johnlukow

I have really enjoyed the site so far. I went beyond the poem and did a MadLib. I created several lists and a general purpose function to return a random of each. Great lessons. I feel like I really understand list. I am not sure how/if I will use Tupel, but I will keep an eye out.

def madlib(type):
    element = random.choice(type)
    return element

# MadLib version

story = ( 
    f"This weekend I am going camping with {madlib(name)}. I packed my lantern, sleeping bag, and\n"
    f"{madlib(noun)}. I am so {madlib(adjective)} to {madlib(verb)} in a tent. I am {madlib(adjective)} we\n"
    f"might see a {madlib(animal)}, they are kind of dangerous. We are going to hike, fish, and {madlib(verb)}.\n"
    f"I have heard that the {madlib(color)} lake is great for {madlib(verb)}. Then we will\n"
    f"{madlib(adverb)} hike through the forest for {madlib(number)} {madlib(time)}. If I see a\n"
    f"{madlib(color)} {madlib(animal)} while hiking, I am going to bring it home as a pet! At night we will tell\n"
    f"{madlib(number)} {madlib(silly_word)} stories and roast {madlib(noun)} around the campfire!!"
    )

print(story)

← Browse All Courses