Python Lesson 1 — Introduction & Variables | LevelUp Cloud Trainings
LevelUp | Learn Python · Lesson 1
Lesson 1 of the Python track · 25 minutes

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.

Zero experience needed Nothing to install 6 live demos
python — lesson1.py
Start here

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

1. Collect order 4471
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

order_id = 4471
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.

S

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.

Live demo 1

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.

Try it — change the message
Output will appear here

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.

The one idea that matters today

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.

Live demo 2 — put a value into a box
=
The value
"Meera"
this is the actual data
The box
no label yet
empty
the name is the sticker
Nothing has run yet.

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.

S

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.

Live demo 3

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.

Watch the box during a delivery
status
"placed"
The box currently holds "placed".
Live demo 4

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.

?Has at least one character
?Starts with a letter or an underscore, never a digit
?Only letters, digits and underscores — no spaces, no dashes
?Is not a word Python has already taken
Valid name — Python will accept this.

Names that work

order_total # clear, lowercase, underscores
customer_name # anyone can read it
gst_rate # short but specific
_temp # legal, means "internal"

Names Python refuses

2ndorder # cannot start with a digit
order total # spaces are not allowed
order-total # that is a minus sign
class # Python already uses this word
S

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.

Live demo 5

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.

price = "180" # text, not a number
qty = 2
print(price * qty)
180180 — it repeated the text twice
price = 180 # a real number
qty = 2
print(price * qty)
360 — that is what you wanted

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.

Live demo 6

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.

FoodieX bill · step through it
Memory — the boxes right now
No boxes yet. Press Step.
 
Press Step to run the first line.
Save yourself an hour

Four mistakes every beginner makes

What breaks
What to write instead
"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.
Check yourself

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.

Lesson 1 check 1 / 5
0 correct
Lesson 1 recap

Four things you now know

01

Python is a list of instructions, written strictly enough that a machine cannot misread them.

02

A variable is a labelled box. The name is the sticker, the value is what is inside.

03

= means "gets", not "equals". It moves the right side into the left.

04

Python cares about type. "180" is text; 180 is a number.

LevelUp Cloud Trainings · levelupedu.net

Sateesh · Microsoft Certified Trainer · 22+ years