These are the notes for Python episode 1. You will learn what programming actually is (a chai recipe!), how Python runs your code with an interpreter, why Python is a great first language, your first program, print() in full detail (quotes vs no quotes, commas, sep, end, escape sequences), how to read Python's error messages, and comments. Every example below runs as-is in the SyntaxPilot compiler, with its real output from Python 3.13.
The problem: a computer can't guess
Imagine teaching a friend who has never been in a kitchen how to make chai:
- Boil the water.
- Add tea leaves and ginger.
- Add milk and sugar.
- Strain it into a cup.
Every step is clear, and the order matters: strain first and boil later, and there is no chai.
A computer is exactly like that friend. It is extremely fast, but it doesn't think for itself. It needs clear instructions, in the right order.
- A program is a list of instructions the computer follows one by one.
- Programming is writing those instructions.
- A programming language (like Python) is a language with strict rules that both you and the computer can understand.
How Python runs your code: the interpreter
You write Python in a file such as main.py. A program called the Python interpreter reads that file and runs it line by line, like a live translator who translates each sentence the moment it is spoken.
| Step | What happens |
|---|---|
| 1. You write code | main.py, in easy, English-like Python |
| 2. The interpreter reads it | python3 main.py translates one line at a time |
| 3. The computer acts | each line runs right away, top to bottom |
| 4. An error stops it | the interpreter stops at the first line it can't run and tells you why |
Because Python runs line by line, lines before an error still run. Lines after it don't.
Why start with Python?
- Readable: Python code looks close to English, so you think about the problem, not the punctuation.
- Short: what takes 5 lines in Java often takes 1 line in Python.
- Everywhere: web apps (Instagram's backend), data science, AI and machine learning, automation scripts, games.
- Huge community: almost every question you will have has already been answered.
The same "Hello, World!" program in Java and in Python:
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
print("Hello, World!")
Your first program
Open the SyntaxPilot compiler (nothing to install), pick Python, and type:
print("Hello, World!")
Output:
Hello, World!
Anatomy of print("Hello, World!")
| Part | Name | Meaning |
|---|---|---|
print |
function name | A function is a ready-made machine that does one job. print's job: show something on screen. |
( ) |
round brackets | Whatever you give the function goes inside. Open a bracket, and you must close it. |
"Hello, World!" |
string | Text in quotes. It prints exactly as written. |
Python is case sensitive: print must be all lowercase. Print is a different (unknown) name.
Quotes vs no quotes: whiteboard vs calculator
Text in quotes is a string: Python copies it to the screen exactly, like writing on a whiteboard. Without quotes, Python calculates first, like a calculator.
print("Hello, World!")
print('Single quotes work too')
print(10)
print(5 + 3)
print("5 + 3")
Output:
Hello, World!
Single quotes work too
10
8
5 + 3
Single quotes and double quotes both make strings. 5 + 3 without quotes is calculated (8); "5 + 3" in quotes is printed as is.
Python as a calculator
print(250 + 120 + 80)
print(450 / 4)
print(450 // 4)
print(450 % 4)
print(2 ** 10)
Output:
450
112.5
112
2
1024
| Operator | Meaning | Example | Result |
|---|---|---|---|
+ - * |
add, subtract, multiply | 250 + 120 + 80 |
450 |
/ |
divide (always a decimal result) | 450 / 4 |
112.5 |
// |
floor division: the whole part only | 450 // 4 |
112 |
% |
modulo: the remainder | 450 % 4 |
2 |
** |
power | 2 ** 10 |
1024 |
Real life: splitting a ₹450 bill among 4 friends, each pays 450 // 4 = 112 and 450 % 4 = 2 rupees are left over.
Text + number: joining with + vs commas
+ between two strings joins them (like coupling train coaches). But + can't join a string and a number:
print("Age: " + "21")
print("Age:", 21)
print("Age: " + 21)
Output:
Age: 21
Age: 21
Traceback (most recent call last):
File "main.py", line 3, in <module>
print("Age: " + 21)
~~~~~~~~^~~~
TypeError: can only concatenate str (not "int") to str
Concatenate means join. A comma inside print() is the safe way: it prints the values side by side with a space between them, whatever their type.
sep and end
print("Python", "is", "fun")
print("Python", "is", "fun", sep="-")
print("Loading", end="...")
print("Done!")
print("Line 1\nLine 2")
Output:
Python is fun
Python-is-fun
Loading...Done!
Line 1
Line 2
- Several values separated by commas print with a space between them.
sep="-"changes that separator (sep = separator).end="..."changes what's printed at the end. By defaultendis a new line, so the nextprintstarts on a new line. Withend="...", the nextprintcontinues on the same line.\ninside a string starts a new line.
Escape sequences
A backslash \ inside a string starts an escape sequence: a special character you can't type directly.
print("Name:\tAarav")
print("He said \"Hi\"")
print("C:\\Users\\Aarav")
print()
print("Done")
Output:
Name: Aarav
He said "Hi"
C:\Users\Aarav
Done
| Escape | Meaning |
|---|---|
\n |
new line |
\t |
tab (lines up columns) |
\" |
a double quote inside a double-quoted string |
\\ |
one backslash |
An empty print() prints a blank line.
Reading errors
An error is like a teacher's red mark: Python tells you what went wrong and on which line. Read the last line first.
Print("Hello")
Traceback (most recent call last):
File "main.py", line 1, in <module>
Print("Hello")
^^^^^
NameError: name 'Print' is not defined. Did you mean: 'print'?
print("Hello)
File "main.py", line 1
print("Hello)
^
SyntaxError: unterminated string literal (detected at line 1)
print("Hello")
(note the space before print)
File "main.py", line 1
print("Hello")
IndentationError: unexpected indent
Comments
A comment is a sticky note for humans. It starts with #, and Python ignores everything after it on that line.
# My first Python program
print("Hello") # prints a greeting
# print("This line will not run")
print("Bye!")
Output:
Hello
Bye!
Putting # in front of a line of code ("commenting it out") switches that line off without deleting it.
Common mistakes (and the real error messages)
| Mistake | Error | Why | Fix |
|---|---|---|---|
Print("Hello") |
NameError: name 'Print' is not defined. Did you mean: 'print'? |
Python is case sensitive | print("Hello") |
print("Hello) |
SyntaxError: unterminated string literal (detected at line 1) |
The closing quote is missing | Close the quote |
print("Hello") |
IndentationError: unexpected indent |
A space at the start of the line | Start at column 1 |
print("Age: " + 21) |
TypeError: can only concatenate str (not "int") to str |
+ can't join text and a number |
print("Age:", 21) |
print("5 + 3") expecting 8 |
no error, prints 5 + 3 |
Quotes mean "print as is" | print(5 + 3) |
Mini project: my profile card
# Mini project: my profile card
print("=" * 30)
print(" Name : Aarav")
print(" City : Lucknow")
print(" Goal : Python Master")
print("=" * 30)
print("Learning", "Python", "with", "SyntaxPilot", sep=" | ")
Output:
==============================
Name : Aarav
City : Lucknow
Goal : Python Master
==============================
Learning | Python | with | SyntaxPilot
"=" * 30 repeats the string 30 times, a quick way to draw a line.
Practice
- Print your name, city and favourite food on three lines.
Solution
print("Aarav")
print("Lucknow")
print("Chole bhature")
- Print today's date as
2026-10-25using three values andsep.
Solution
print(2026, 10, 25, sep="-")
Output: 2026-10-25
- Print
Loading... 100%using twoprintcalls.
Solution
print("Loading", end="... ")
print("100%")
- Print this pattern:
*
**
***
Solution
print("*")
print("*" * 2)
print("*" * 3)
- Each of 4 friends pays an equal share of ₹450. Print each share (whole rupees) and the rupees left over.
Solution
print("Each pays:", 450 // 4)
print("Left over:", 450 % 4)
Output: Each pays: 112 and Left over: 2
Quick quiz
What does this print?
print("2 + 3", 2 + 3)
A) 2 + 3 2 + 3 B) 5 5 C) 2 + 3 5 D) Error
Answer
C) 2 + 3 5. The first value is in quotes, so it prints as is; the second is calculated (5). The comma adds a space.
Interview questions
- Is Python compiled or interpreted? Python source is run by an interpreter (CPython first compiles it to bytecode, then the Python virtual machine runs that bytecode line by line). For beginners: you run
.pyfiles directly, with no separate compile step. - What's the difference between
/and//?/is true division and always returns a float (7 / 2 = 3.5);//is floor division (7 // 2 = 3). - What do
sepandenddo inprint()?sepis placed between values (default a space),endis printed after the last value (default a new line). - Single or double quotes? Both create strings; use the other kind when the text contains a quote.
- How do you write a comment? With
#. Python ignores the rest of the line.
Glossary
| Term | Meaning | Example |
|---|---|---|
| Program | A list of instructions the computer follows in order | a chai recipe for the computer |
| Programming | Writing those instructions | writing main.py |
| Programming language | A language with strict rules that people and computers both understand | Python, Java |
| Interpreter | The program that reads Python code and runs it line by line | python3 main.py |
| Function | A ready-made machine that does one job | print() |
String (str) |
Text inside quotes | "Hello" |
| Output | What a program shows on the screen | Hello, World! |
| Concatenate | Join strings end to end | "Age: " + "21" |
sep |
What print() puts between values |
sep="-" |
end |
What print() puts after the last value |
end="..." |
| Escape sequence | A backslash code for a special character | \n, \t |
| Error / exception | Python's message that something went wrong, and where | NameError |
| Traceback | The error report, read from the bottom | Traceback (most recent call last) |
| SyntaxError | The code breaks Python's grammar rules | a missing quote |
| IndentationError | Spaces at the start of a line where none belong | print("Hi") |
| Case sensitive | Capital and small letters are different | print vs Print |
| Comment | A note for humans, ignored by Python | # my note |
Summary
- A program is a list of clear instructions, in order, like a recipe.
- The Python interpreter runs your code line by line, top to bottom.
print()shows output. Quotes print text as is; no quotes means calculate.- Commas print values side by side;
sepandendcustomise that;\nand\tare escape sequences. - Read errors from the last line up: what went wrong, and which line.
#starts a comment.
Next episode: variables and data types, giving your data a name so you can use it again.