Introduction & print()
print("Hello, World!")You write an instruction. print() means “show this on the screen”.
1Level 1 · BasicsBasics
Welcome! This first lesson assumes you have never written code before. By the end you'll have run your first Python programs right here in the browser. You don't need to install anything.
What is programming?
A program is a list of instructions for a computer. The computer follows them exactly, one line at a time, from top to bottom. A programming language is the way we write those instructions. Python is one of the most popular languages in the world because its code reads almost like English.
People use Python for websites, automating boring tasks, games, data analysis, science and machine learning. Everything you learn here, from print() to pandas, is the same Python the professionals use.
Your first instruction: print()
print() shows something on the screen. Whatever you put inside the round brackets is printed:
print("Hello, world!")
- Text goes inside quotes. Double quotes
"hi"and single quotes'hi'both work. A piece of text is called a string. - Numbers don't need quotes:
print(42). You can even do maths:print(2 + 3)prints5. - Each
print()starts on a new line.
Printing several things at once
Separate items with commas. Python puts a space between them:
print("I am", 20, "years old") # I am 20 years old
Two optional settings change this. sep sets what goes between the items, and end sets what goes at the end (normally a new line).
How to use the examples
Every lesson has editors with a ▶ Run button. Press it to run the code. Then change something and run it again. Breaking things on purpose is a great way to learn. Reset brings the original code back.
Key points: a program runs from top to bottom; print() shows output; text needs quotes, numbers don't; commas print several items with spaces between them.See it in actionPython runs one line at a time
Press Play and watch the arrow move down the program. Each print() adds a line to the output.
Try it yourselfExample 1: Hello, world
Press Run. Then change the message to your own name and run it again.
Output appears hereSay hello
Fill the blank so the program prints Hello, Python!.
print()
Example 2: Maths inside print()
Python works out the sum first, then prints the answer. Text in quotes is printed exactly as written, even if it looks like maths.
Output appears hereA missing quote
This should print I love coding, but Python stops with an error. Press Check to see it, then fix the line.
Example 3: sep and end
sep goes between items; end goes after the last one. Try sep=", " or end="!!!\n".
Output appears hereJoin with dashes
Fill the blanks so the output is 2026-11-06 (no spaces).
print(2026, 11, "06", ="")
Two lines, one print
Using one print() call, print Name: Mim on the first line and Class: 7 on the second.
Example 4: A tiny receipt
Several print() lines together make a small, readable output.
Output appears hereLet Python do the maths
A notebook costs 45 taka and a pen costs 15 taka. Print Total: 60, letting Python add the two prices.
2Level 2 · IntermediatePrinting like a pro
You can already print text and numbers. Now let's control exactly how the output looks.
Escape characters
Inside a string, a backslash starts a special character: \n is a new line, \t is a tab, \" is a quote mark and \\ is a backslash itself.
print("Name:\tRahim\nAge:\t15")
Multi-line strings
Three quote marks let a string run over several lines, exactly as you type it. Handy for menus, poems and ASCII art.
Repeating text
"-" * 20 makes a line of 20 dashes. Multiplying a string by a whole number repeats it.
See it in actionWatch print() build the output
Step through and watch each print add to the output, including the line breaks from \n.
Example 5: Escape characters and repeated lines
Change the tab \t to a few spaces and compare the alignment.
Output appears hereExample 6: A multi-line menu
Triple quotes keep every line break you type.
Output appears here3Level 3 · AdvancedHow Python runs your program
Before going further, it helps to know what happens when you press Run.
Interpreted, line by line
Python reads your file from top to bottom. It first checks the whole file for syntax errors (like a missing bracket). If there are none, it runs the lines in order. An error in line 5 means lines 1 to 4 already ran.
print() is a function with options
print(*values, sep=" ", end="\n"): it takes any number of values, joins them with sep and finishes with end.
Syntax errors stop everything
A syntax error (like a missing bracket or quote) is found before anything runs, so not even the first line prints. A runtime error (like dividing by zero) happens while running, so the lines before it have already printed.
Remember: Python stops at the first error it meets while running, so read error messages from the bottom line up.
See it in actionPython stops at the first error
Watch lines 1 and 2 run, then line 3 raise an error. Line 4 never runs.
Example 7: A neat receipt with aligned columns
Python works out each total for you. Add a line for an eraser that costs 5 Tk and fix the grand total.
Output appears hereExample 8: Lines run in order until an error
The SyntaxError is a mistake in the code itself, so nothing runs at all, not even line 1. Fix the missing bracket and run again.
Output appears herePrint("hi") gives a NameError because the function is called print in lowercase. Also check your quotes match: print("hi') is a SyntaxError.What does this program print?
print("Py", "thon", sep="")50 graded problems are waiting in Topic Practice.