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_of_pets = 3
A string helps you store text.
dog_name = "spot"
A boolean is a true or false value.
is_favorite_fruit = True;
favorite_fruits = ["banana", "apple", "pear"]
A tuple is a read-only list; you can't add or remove items.
favorite_fruits = ("banana", "apple", "pear")
letters_to_words = {
"a": "apple",
"b": "boy",
"c": "car"
}
Variables can also store functions and objects (we'll talk about these soon).
Next: Numbers in Python
Leave a comment