Python is just you, telling a computer what to do — one line at a time.
No jargon, no theory dump. In the next twenty minutes you will write your first line of Python, understand exactly what a variable is, and watch one run in front of you. Everything on this page is live — press the buttons, change the values, break it on purpose.
You already know how to give instructions
When you order from Swiggy, somebody follows a list: pick up the order, drive to the address, hand it over, mark it delivered. Nobody calls that programming. But that is exactly what it is — steps, in order, that somebody else carries out.
Instructions for a delivery partner
2. Go to Banjara Hills
3. Hand it to Meera
4. Mark it delivered
A human reads this and knows what to do.
The same instructions for a computer
area = "Banjara Hills"
customer = "Meera"
status = "delivered"
A computer reads this and knows what to do. Same idea — stricter spelling.
So what is Python, really?
Python is one of many ways to write those instructions. It became the most popular one because it reads closer to English than most alternatives. Compare how you say "add these numbers up" in Python versus in Java, and you will see why a beginner starts here.
You do not need to install anything today. Everything on this page runs in your browser, and everything you write in the real Python later works exactly the same way.
Sateesh Says Do not get stuck on "what is a programming language". You have been writing instructions your whole life — recipes, directions to your house, a WhatsApp message telling your brother which shop to go to. Python is that, typed carefully enough that a machine cannot misunderstand you.
Your first line of Python
There is one instruction every Python programmer writes first:
print(). It means "show this on the screen". Type anything between the quotes
and press Run.
The round brackets say "do this thing". The quotes say "this is plain text, not a command". Miss either one and Python stops and tells you — which is a good thing, not a failure.
A variable is a labelled box
Think of a lunch dabba with a name sticker on the lid. The sticker says
customer. Inside is the actual thing — "Meera". Later, when you want
what is inside, you do not describe the food. You just say the name on the sticker.
Read the = sign backwards
customer = "Meera" does not mean "customer is equal to Meera" the way
it did in your maths class. It means: take the thing on the right, and put it in the
box named on the left. Right to left. Always.
The box only holds one thing
Put a new value into the same box and the old one is gone — not sitting behind it, gone. That is why the demo below throws the old value out before the new one drops in.
Sateesh Says Ninety percent of beginner confusion comes from reading
= as "equals". It is not equals. It is an arrow pointing left. Say it out loud as
"gets" — customer gets Meera — and half the confusion disappears in one sitting.
Changing what is in the box
This is where the word "variable" comes from — the value can vary. Press the buttons and watch the old value get pushed out before the new one lands.
What you can call a box
Python is strict about names, and the rules take two minutes to learn. Type a name below and watch each rule light up.
Names that work
customer_name # anyone can read it
gst_rate # short but specific
_temp # legal, means "internal"
Names Python refuses
order total # spaces are not allowed
order-total # that is a minus sign
class # Python already uses this word
Sateesh Says x and a1 are legal names and they are
still bad names. Six months from now you will open your own file and have no idea what
x held. Write order_total. The extra typing costs you four seconds
and saves you an afternoon.
Python cares what kind of thing is in the box
A number and a piece of text look similar to you. To Python they are completely different, and it behaves differently with each. Tap any value to see what Python calls it.
The mistake everybody makes on day one
A number wrapped in quotes is not a number. It is text that happens to look like one. Watch what happens when you try to add it up.
qty = 2
print(price * qty)
qty = 2
print(price * qty)
If a number arrives as text — and it will, every time you read a file — convert it with
int("180") first. Going the other way, str(180) turns a number
into text so you can join it onto a sentence.
Watch a real program run, one line at a time
This is Meera's FoodieX bill. Press Step and follow which line runs and what lands in memory. This single habit — tracing by hand — is how you debug for the rest of your career.
Four mistakes every beginner makes
"Meera" = customer
Backwards. The box name always sits on the left of the =.customer = "Meera"
Right side goes into the left side. Read it as "customer gets Meera".customer = Meera
Without quotes Python looks for a box called Meera, finds none, and stops
with a NameError.customer = "Meera"
Quotes mean "this is plain text". No quotes means "this is a name I defined".Print("hello")
Capital P. Python is case-sensitive, so Print and print
are two different words.print("hello")
Lowercase. The same rule bites you with Total versus
total.order total = 400
The space makes Python read two separate things and give up.order_total = 400
Underscores instead of spaces. This style has a name: snake_case.Five questions before you move on
No score is saved anywhere and nobody sees it. Getting one wrong here is worth more than getting it wrong in an interview.
Four things you now know
Python is a list of instructions, written strictly enough that a machine cannot misread them.
A variable is a labelled box. The name is the sticker, the value is what is inside.
= means "gets", not
"equals". It moves the right side into the left.
Python cares about type. "180"
is text; 180 is a number.