Locked learning resources

You must own this product to watch this lesson.

Locked learning resources

You must own this product to watch this lesson.

Variables in Python: Summary

Note: this summary lesson includes a slide about small integer caching, which was not covered in these lessons. You can ignore references to small integer caching.


This lesson is part of a Real Python video course by Martin Breuss.

00:00 All right! To wrap up this course, let’s go quickly over the most important takeaways that we talked about.

00:08 First of all, variable assignment. It looks like this in Python. It’s very simple. On the left side you put the name of the variable, an equal sign (=), and then the value.

00:17 That’s just how it works in Python. And what it does is it creates a reference from a name to an object that gets created in memory. All right. So, I mentioned the term object.

00:29 What I want you to take away is that everything is an object in Python, be it a string, an integer, an object that you create yourself, or even a function.

00:37 Everything’s an object. And with the variables, you’re pointing to different objects in memory.

00:44 Then we talked about something surprising in Python which is explained by the fact that Python caches small integers for performance improvements. And there’s also a little challenge that I suggest you to do if you haven’t done it yet.

00:57 Just get your brain to think about it, it’s a fun thing, and it’s something that you can challenge your friends with as well. Next, we looked at variable naming conventions.

01:04 We said that variables can have any length. They can be very short or very long. They can be upper or lowercase characters or a mix of both, but take care with mixing them. The snake is watching you, ha. Generally, you want to use snake case. That is a mix of lowercase characters and underscores (_). Therefore, underscores are fine to be used.

01:23 You can use digits inside of your variables, but you cannot use the digits at the beginning or just only digits. That’s not okay in Python. And since Python 3, also Unicode characters are supported. And finally, we took a look at reserved keywords in Python and the quickest and easiest way to get help on what those are is to type in help() and the string "keywords", and Python’s going to print you out a list of the keywords that you cannot use as variable names because they have a special meaning in Python. And that wraps it up!

01:56 I hope you had fun in this course and that you learned something. See you in the next one!

You must own this product to join the conversation.