Your browser does not support JavaScript!
Upvotes Anonymous 2 User 0

Variables in Python

A variable is a place to store things. In Python, variables are given a name, and can store different types of things. Below are some examples. 

Don't worry about understanding everything at this point; there will be examples later.

Number
number_of_pets = 3

String (text)
dog_name = "spot"
Boolean
is_favorite_fruit = True;

List
favorite_fruits = ["banana", "apple", "pear"]

Tuple (a read-only list, you can't add or remove items)
favorite_fruits = ("banana", "apple", "pear")

Dictionary
letters_to_words = {
    "a": "apple",
    "b": "boy",
    "c": "car"
}
Variables can also store functions and objects (we'll talk about these soon).
Was this helpful?

Tags

Comments

Leave a Comment

I agree to the Terms of Service
Design © 2015, Downranked, LLC.,
Original user code contributions under MIT License