Assigning and printing Python variables (Python 3 )

Assigning and printing Python variables

Variables allow us to store things in memory for as long as the Python program runs. Like a restaurant reservation under your name, a variable is a named reservation of a small part of your computer's memory.

We assign a value to a variable using the = sign. E.g., to assign the number 42 to a variable called age, we would write age = 42.

Just like numbers and strings, we can print a variable with the print() function. In this case, we print a string and the variable at once. To do so, we can give print multiple values separated with commas.

Edit and run this Python 3 example code

This code is editable and runnable. You can run "Assigning and printing Python variables" by pressing the run button. It will be executed in our backend and the result (stdout and stderr) is displayed in addition tabs.

Share "Assigning and printing Python variables"

Share this crumb (Assigning and printing Python variables) with your friends and colleagues to help them learn more about Python 3 programming.

Twitter, Facebook, LinkedIn

On Twitter, Facebook, and LinkedIn, simply paste the URL in your post and watch the magic unfold.


If you want to embed the crumb in an iframe, use the following code:

oEmbed (WordPress)

We support oEmbed, but most sites use allowlisting. On WordPress, oEmbed is supported out of the box, but see the note below.

If you plan to use heavily on Wordpress, you can use the following PHP code to allowlist our site and unlock all the functionalities of our crumbs:
wp_oembed_add_provider( '*', '' ); is a service that allows you to embed content from other sites. We will request to be added to the list of trusted sites once we're out of beta.