Python Syntax Basics
Syntax means the spelling rules of Python.
Like grammar for a language you speak.
If a line breaks a rule, Python stops and asks you to fix it.
Good news: the rules are few and friendly.
Indentation is the big rule
Python uses spaces at the start of a line to show groups.
Think of nest boxes. Nested toys sit inside the bigger box.
Lines under if, for, or def must be pushed in.
Usually people use 4 spaces.
Colons start a block
A colon : means, next lines belong to me.
You see it after if, else, for, while, and def.
Comments are notes for humans
A hash mark starts a comment.
Python ignores that part.
Use comments like sticky notes on a recipe.
Statements and newlines
Most of the time, one idea gets one line.
Python reads top to bottom, like a story.
Write one clear step per line
Keep names short and honest
Match your spaces carefully
Fix errors from the top down
Case matters
Print and print are not the same.
Python is picky about big and small letters.
Built-in tools use lowercase names, like print.
Quotes for text
Text needs quotes.
Single or double quotes both work.
Pick one style and stay with it in a file.
Tip: When Python complains about indent, check spaces under the colon line.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.