Variables In Python

In this page, I quickly go over variables in Python.

(Reference: Starting Out With Python – Second Edition By Tony Gaddis)


What Is A Variable?

A variable stores a value into a computer’s memory.¬†Variables can be numeric values, text/strings, or a list. You may think of a variable like a bucket or container in which something is stored in it.




Examples Of Variables

I present three types of variables that can be used in Python. Keep in mind that there are more out there.




Printing Variables

You can display the contents from the variables in Python with the print() function.



Embedding Variables In print()

You can include variable contents with text/strings in Python’s print() function. Text is surrounded by single quotes and variables are separated by commas.

In the example below, the value of age and the fruit variable is combined with the text in quotes.




Leave a Reply