What is Syntax?
Syntax is just a fancy word for "The Rules".
Just like English has grammar (periods, commas, capital letters), Python has Syntax.
If you break the rules, the robot gets confused! ๐คโ
Make it Talk (Print)
The first thing to learn! Tell the computer to say something on the screen.
Don't forget the parentheses ()!
Speech Bubbles (Strings)
Computers don't know what words are. You have to wrap them in quotes.
If you forget quotes, it thinks you're talking about a variable!
Memory Boxes (Variables)
Save things for later! Give a name to a value so you can use it again.
Now score is a shortcut for 100.
Super Calculator (Math)
Computers are great at math. You can use them like a calculator.
Use * for multiply and / for divide.
Making Choices (If/Else)
Teach the robot to make decisions based on rules.
โ ๏ธ IMPORTANT: See the indentation (space)? That tells Python what belongs inside the "If".
Looping (Repeat)
Don't be boring! Use a loop to do things over and over again.
This counts from 0 to 4 (5 times total). Computers start counting at 0!
Secret Notes (Comments)
Sometimes you want to leave a note for yourself that the computer ignores.
Use the hashtag # to make a comment.
Bugs (Errors)
Did the screen turn red? Don't panic! It just means you broke a syntax rule.
- Forgetting a quote "
- Forgetting a parenthesis )
- Forgetting the colon :
- Messing up the spaces (Indentation)
Read the error message, fix the typo, and try again!
You know the rules. Now play the game!
Start Coding Now ๐