Variables
This time, let us talk about variables.
What is a variable?
A variable is a way to tell the computer to remember something.
Let us start with Python again.
Delete print("Hello, Python!"), and type:
x = 2026
y = "Hello, Python!"
in PyCharm.
Does it feel a bit clearer now? If we translate this into plain English:
Remember that x is 2026
Remember that y is "Hello, Python!"
Now run it.
Huh? Nothing shows up.
If you think about it, we told the computer to remember things, but we never told it to print them.
So let us print what we stored. Add this under your code:
print(x)
print(y)
Now you will see:
2026
Hello, Python!
Before, we printed “Hello, Python!” directly.
This time, we stored values in x and y, and then told the computer to print them.
This is how we make the computer remember things.
What can the computer remember?
What the computer can remember is limited. Unlike a person, it cannot just understand anything you say.
Here are the kinds of values it understands. Try typing this in PyCharm:
number = 2026
decimal = 3.14
text = "Hello"
true_value = True
false_value = False
items = ["number", "decimal", "text", "true_value"]
print(number, decimal, text, true_value, false_value, items)