Python Basics Exercises: Tuples and Lists (Overview)

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.

Download

Sample Code (.zip)

3.7 KB
Download

Course Slides (.pdf)

5.6 MB

00:00 Welcome to this Real Python Exercises course where you’ll practice working with tuples and lists, which are two of Python’s data types that represent collections.

00:09 Our exercises courses are all about training. You’ll train the process of writing code by solving carefully selected exercises. You’ll also train reading other people’s code and communicating your thought process.

00:22 Doing all that, you’ll practice the concepts that you’ve learned about in an associated course or tutorial and help make them stick.

00:29 In the upcoming lessons, I’ll introduce you to tasks, give you an opportunity to solve them yourself, and then show you step by step how I solved each of them.

00:37 You’ll go through three steps for each task. You’ll learn about the exercise, you’ll code your own solution, and then you’ll compare your solution and the process that got you there to mine.

00:48 When I walk you through a task, I’ll explain what I do and also why I do it like that. That’ll give you a chance to compare not just our final solutions, but also how I got there.

00:56 Ideally, this can help you gain some insights on the process of getting from a task description to a working solution in code. In this course, you’ll start with solving some review exercises in the first section of the course, and then build towards a challenge.

01:11 The challenge in this course will be to build a poetry generator, and you’ll get to train using lists and tuples in a slightly bigger project.

01:19 Okay, so now the big question. Are you ready for this course? The idea of this exercises course is that you should have watched the Python Basics course on tuples and lists before starting this one.

01:29 If you went through that course, then you’re well equipped to solve the tasks that you’re about to encounter.

01:34 The concepts that you should have heard about and will practice are of course tuples and lists. You’ll train different aspects of these data structures, such as indexing, slicing, tuple unpacking, list comprehensions, and mutability.

01:48 You’ll also train other concepts such as conditional logic and loops, but these won’t be the focus of the exercises. If you’re already somewhat familiar with these concepts and you want to fortify your knowledge with practical programming tasks, then this course is exactly right for you.

02:04 Before you get started, there’s another tiny bit of background for this course, which is that I’ll use IDLE, the integrated development and learning environment that comes with Python.

02:13 If you’ve gone through the Python Basics courses, then you’re already familiar with the tool. If not, and you want to know more, then you can check out these associated courses that cover getting started with IDLE.

02:23 But you don’t need to use IDLE specifically, any other Python session and code editor will do. So if you’re here to train outside of the Python Basics course, then feel free to use whatever tool you like to solve the upcoming coding tasks,

02:37 and that’s all to get you set up. Are you ready to do some hands-on programming? What about you, Mouse Fox? Looks like everyone’s ready. So let’s get started with the first review exercise in the next lesson.

Become a Member to join the conversation.