⬅ Previous Topic
Python Comments Explained - Beginner’s Guide with ExamplesNext Topic ⮕
Python Constants⬅ Previous Topic
Python Comments Explained - Beginner’s Guide with ExamplesNext Topic ⮕
Python ConstantsImagine you have a box where you can store anything you want — a number, a word, or even a whole sentence. In Python, we use something called a variable to store information like that!
A variable is like a label you stick on a box to remember what’s inside.
For example, you can create a variable called name
and store your name in it:
name = "Alice"
Here, name is the variable, and "Alice" is the information we are saving inside it.
Let's save a number in a variable:
age = 25
Now, the variable age
holds the number 25
.
After you create a variable, you can use it whenever you want. For example:
print(name)
print(age)
When you run this code, Python will show:
Alice
25
_
instead. (Example: my_age
)price
is better than p
.)Variables help you save information in Python so you can use it later. You can store words, numbers, or other things — all by just giving them a name!
In the next lessons, you will learn more about working with different types of information!
⬅ Previous Topic
Python Comments Explained - Beginner’s Guide with ExamplesNext Topic ⮕
Python ConstantsYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.