Introduction
Python is a programming language. A programming language is a way to give instructions to a computer. You write words and symbols in a special order, and the computer follows them. Python is famous because its instructions look almost like plain English, so beginners can read and understand them quickly.
Python is used in many real places: websites, small tools, data work, automation (doing boring jobs automatically), and games. Big companies use it, and small learners use it too. That is why it is a good first language — you learn real skills, not just school examples.
The best way to start is to write one small program and run it. In Python, the command print() shows text on the screen. It is the first command almost every learner writes, and it is the first command you will write in this lesson.
(Roman Urdu: Python aik aasaan programming language hai — is ke alfaaz aam English jaisay lagtay hain, is liye naya seekhnay wala bhi isay jaldi samajh leta hai.)
Beginners sometimes think coding means typing a lot at once. It does not. Start with one line, run it, read what comes back, then add the next line. That small loop — write, run, read — is how every programmer works, even on big projects.
Key points
- Python is a high-level language. You write simple words like
printandif, not the tiny machine codes a computer uses inside. - Python is easy to read. It uses spaces and clear words instead of lots of brackets and symbols, so code looks clean.
- Python is free and popular. Anyone can download it, and there are thousands of free lessons, examples and helpers online.
- Python runs line by line. The computer reads the first line, runs it, then moves to the next line. This is called being an interpreted language.
- Indentation matters in Python. Spaces at the start of a line are not decoration — they show which lines belong together, for example inside a loop or a condition. You will practise this from lesson PY.6 onwards.
- Your first program is always small. One or two lines are enough. Do not try to build a big app on day one.
- Errors are normal. Every programmer sees error messages. An error is a message that tells you what to fix, not proof that you cannot code.
- Comments start with
#. Anything after#on a line is a note for humans; Python ignores it completely. - Run early and often. Do not write twenty lines and then run for the first time. Run after every few lines, so a mistake is easy to find.
Examples
Example 1 — Your first program
Type this into a file called hello.py, or into an online Python runner, and run it:
print("Assalam o Alaikum")
print("Hello, World!")What you will get on the screen:
Assalam o Alaikum
Hello, World!Each print() shows one line. The text inside the quotes is printed exactly as you wrote it.
Example 2 — Python can also do maths
Python is also a calculator. Try this:
print(2 + 3)
print(10 * 4)
print("I am learning Python")What you will get:
5
40
I am learning PythonNumbers without quotes are treated as numbers, so Python adds and multiplies them. Text inside quotes is treated as words, so Python prints it as it is.
Example 3 — Running code, step by step
Here is a tiny program with three lines:
print("Step 1: Start")
print("Step 2: Learn")
print("Step 3: Practise")What you will get:
Step 1: Start
Step 2: Learn
Step 3: PractisePython runs the lines from top to bottom, in order. If you change the order of the lines, the output order changes too.
Example 4 — Comments: notes Python ignores
A comment explains your code to a future reader — including future you. Python skips it when running:
# This line is a note, Python ignores it
print("Hello") # This prints a greetingWhat you will get:
HelloUse comments to say why you wrote something, not just what it does — the code already shows the what.
Example 5 — A tiny calculator with variables
Instead of typing numbers straight into print(), store them first. Then the maths is easy to read and easy to change:
price = 150
quantity = 3
total = price * quantity
print(total)
print("Total bill:", total)What you will get:
450
Total bill: 450Change quantity to 5 and run it again — the total updates by itself, because it is calculated, not typed in.
Example 6 — Real-world case: a small shop's daily total
A shopkeeper sells tea at 20 rupees a cup and snacks at 30 rupees a packet. At the end of the day, a few lines of Python add up the sales — no calculator, no paper:
# A small shop's sales for one day
tea = 20 * 50
snacks = 15 * 30
print("Tea sales:", tea)
print("Snacks sales:", snacks)
print("Day total:", tea + snacks)What you will get:
Tea sales: 1000
Snacks sales: 450
Day total: 1450This is where Python is actually used in real life: small, boring, repeated calculations done fast and without mistakes.
Quick recap
- Python is a simple, readable programming language.
print()shows text or numbers on the screen.- Text goes inside quotes; numbers do not need quotes.
- Python runs your code line by line, from top to bottom.
- Errors are normal messages that tell you what to fix.
- Comments with
#are notes for humans; Python ignores them. - Variables can hold numbers, so Python can work out a total before printing it.
Common mistakes
- Forgetting the brackets after print — writing
print "Hello"gives an error. Fix: always writeprint("Hello")with brackets. - Mixing up quotes — starting with
"and ending with'confuses Python. Fix: open and close with the same kind of quote. - Typing code with spelling mistakes —
prnt("Hello")is not a command Python knows. Fix: check the spelling of every command, letter by letter. - Running nothing and wondering why nothing happens — writing code is only half the job. Fix: press Run, or run the file, and read the output.
- Saving the file with the wrong ending — a file called
hello.txtwill not run as Python. Fix: save it ashello.py. - Writing
Printwith a capital P — Python commands are case-sensitive, soPrint("Hello")is not the same asprint("Hello"). Fix: use small letters forprint.
Practice
- Write a program that prints your name on one line and your city on the next line. Run it.
- Write a program that prints three maths answers:
5 + 5,7 * 6, and100 - 25. Check each answer by hand. - Change the order of the lines in Example 3 and run it again. Write down what changed in the output.
- Try printing a sentence in Roman Urdu, for example
print("Mujhe Python seekhna hai"). Run it and see the result. - Write a program that prints three lines about your day, with a comment above each line saying what the line is about. Run it.
- A notebook costs 80 rupees. Use variables to work out the cost of 4 notebooks, and print the total with a label, like Example 5.
- Print your daily routine in four lines, in order. Then swap two lines and run it again. Write down, in one line, what changed and why.
Practice quiz
Tap an answer to check it — a right answer turns green, a wrong one turns red and shows the right answer. Nothing is scored or saved; this is just for practice.
1. What is Python?
2. What does print() do in Python?
3. Why do beginners often start with Python?