ELI5: How to code python
Explained with writing a simple playbook of rules
Coding in Python is like writing a simple playbook of rules and drills that teaches your computer how to be the ultimate teammate and win the game.
Imagine you are the head coach of a soccer team, and your computer is a player who listens to every single word you say. Python is the friendly, easy-to-understand language you use to shout instructions from the sidelines.
To write a winning playbook in Python, you use just a few basic sports tools:
- Variables are like your team scoreboard or equipment bags. They simply hold important information. You can have a bag labeled score that holds the number ten, or a bag labeled MVP that holds a player's name.
- If-Statements are like the referee's whistle. They help your computer make quick decisions during the match. For example, you can tell your player: if the ball crosses the goal line, celebrate! Otherwise, keep running.
- Loops are like practice drills that your team repeats until the coach blows the whistle. Instead of telling a player to do twenty jumping jacks one by one, you just tell them to repeat the drill until the timer hits zero.
- Functions are your favorite trick plays. Instead of explaining every single step of a corner kick every time it happens, you give the entire routine a cool nickname. Whenever you shout that nickname, your player runs the whole play automatically.
To actually start playing, you just grab a digital clipboard, which is a simple text program on your computer. You write down your instructions using simple words that look almost like plain English.
When you are ready, you blow the whistle by pressing the run button. Your computer follows your playbook step-by-step at lightning speed, passing data and scoring goals exactly the way you planned.
Ask your own question
Follow-up questions
Test yourself
Three quick questions to see if it stuck. You can challenge a friend after.
Get this entry by email
We'll send it to your inbox, plus one good explanation a week if you like.