Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Variables in Python: Summary

Give Feedback

In this course, you covered the basics of Python variables, including object references and identity, and naming of Python identifiers. You now have a good understanding of some of Python’s data types and know how to create variables that reference objects of those types.


Course Slides (PDF)

1.0 MB

derekm on Dec. 10, 2019

Good overview. Reinforced a couple of things for me.

princer800 on Dec. 13, 2019

Enjoyed it and good explanation on how Python handles variable objects. DO see some variation from course between Windows and Linux versions.

Asif on Dec. 14, 2019

This stuff is really helpful… thank you!

Adrian on Jan. 29, 2020

Was unaware of small integer caching … thx!

Martin Breuss RP Team on Jan. 29, 2020

Glad that you’ve enjoyed it and happy if it’s been helpful :)

emalfiza on Feb. 27, 2020

Martin B, totally enjoyed learning new stuffs from your course.

Sandro on March 2, 2020

The snake is… ever watchful!

Nice intro on small integer caching. Hoping that I understood it right, all those integers are automatically instantiated as objects and remain so for the entire session, never to be garbage-collected?

Seeing it another way, is Python “encouraging” us to use those numbers throughout the program (e.g. if I need to refer to the figure of 10000, then try to use 10 throughout the code, then adjust the final figure by x 1000? Or is that not a concern?

Thank you,

Martin Breuss RP Team on March 5, 2020

This is a great question and I don’t have a great answer for it myself. I can tell you that for any program you are likely to write at the beginning of your programming journey (and probably way into it as well, tbh) it doesn’t matter.

I’m sure that there are applications that need to really edge out speed and memory usage in order to perform, especially when handling huge amounts of data. However, it is likely that if speed and memory-lookup performance is that important for your app, your company might use a different programming language altogether, since that is not Python’s main area of strength.

There’s an interesting answer on StackOverflow with a ton of links that can lead you onwards, if you want to learn more about this topic. It doesn’t specifically go into Python, but you might still find something enlightening in there. Hope that helps a little and keep on investigating! :D

Sandro on March 5, 2020

Thank you, Martin! Yes that is exactly what I was thinking of: memory usage and speed. You’re right, Python is considered a slower language than its counterparts like C++. Will check the link you posted. :)

kingjay2498 on March 12, 2020

Hello my name is Jay , new to coding an really enjoy the course , lesson was detail an clear . Will continue to study an learn more .

markthiele on March 16, 2020

Thanks, helps a lot!

avalidzy on April 6, 2020

Of what constitutes an “object” in terms of variables. Apparently small integers from -5 through 256 are a special class of objects.

Martin Breuss RP Team on April 6, 2020

Hi @avalidzy. Small integers are normal objects like any other object is an object in Python. The “special” thing about them is only that Python doesn’t create a new instance of an object (= a new object) each time you reference an integer in that range. Instead it refers to that integer object that already exists. It’s a performance thing, but doesn’t make small integer objects special in any way. Hope that makes sense!

avalidzy on April 6, 2020

Thanks for clarifying the nature of a python object! ;)

pshapard on April 21, 2020

Thanks for this video. It was helpful. Onto the next video.

jeffgorzen on May 3, 2020

Could you show how to set a data type at input like a = 39 {int8}?

Martin Breuss RP Team on May 4, 2020

Hi @jeffgorzen. Python is a dynamically typed language, which means you don’t declare the data type of variables when you declare them. The interpreter figures it out at runtime.

You can read more about some more recently introduced ways of adding type checking functionality in the Python Type Checking article.

Konstantin Schukin on June 19, 2020

Thank you, Martin, for the good and clear lessons.

Alain Rouleau on July 26, 2020

Really enjoyed the course, thanks!

Become a Member to join the conversation.