Python Basics Exercises: Scopes (Overview)

On your Python journey, you’ve worked with functions and loops. To fully understand functions and loops in Python, you need to be familiar with the issue of scope.

In this Python Basics Exercises video course, you’ll practice:

  • Identifying the scope of objects
  • Working with the global keyword
  • Exploring the LEGB rule for scope resolution
  • Using the return statement in a function

Scope can be one of the more difficult programming concepts to understand, so in this video course, you’ll get additional practice working with it.

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. If you’re just getting started, then you might want to check out Python Basics: Setting Up Python before diving into this course.

Download

Sample Code (.zip)

3.8 KB
Download

Course Slides (.pdf)

5.3 MB

00:00 Hello, hello, hello. I’m Philipp with Real Python and I’m super happy that you’re joining me today on this Python Basics Exercises course, where you will practice scopes.

00:10 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 over other people’s code and communicating your thought process.

00:24 Doing all that, you’ll practice the concepts that you’ve learned about in an associated course or tutorial and help make them stick. 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:41 You’ll go through three steps for each task, learn about the exercise, code your own solution, and then you’ll compare your solution with mine. When I walk you through a task, I’ll explain what I do and also why I do it like that.

00:56 That will give you a chance to compare not just our final solution, but also how we got there.

01:03 Before starting this course, you should have watched the Python Basics course on scopes. If you went through that course, then you are well-equipped to solve the tasks that I’ll throw at you.

01:14 The concepts that you will practice in this course will be spotting scopes, working with the global keyword, exploring the locals() function, and using the return statement.

01:26 If you’re somewhat familiar with these concepts and you want to strengthen your knowledge with some practical programming tests, then this course is exactly right for you.

01:35 You’ll also organize a small party, so any previous knowledge about that is helpful, but luckily not needed because sometimes spontaneous parties are the best parties.

01:46 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 bundled with Python.

01:57 If you’ve gone through the Python Basics courses, then you are already familiar with the tool. If not, then you can check out these associated courses that cover getting started with IDLE.

02:08 If you are just here to train and you’re familiar with other code editors, then feel free to use whatever tool you like to solve the upcoming coding tasks.

02:17 Alright, that’s all for the preparations. Let’s have some fun.

Become a Member to join the conversation.