Programming logic — variables, conditions, loops
Be able to follow and predict what a short program does: how variables change, when a condition is true, and how many times a loop runs.
Prerequisites
- BAlgorithmic thinkingrequired
Intuition
Three concepts carry all of programming:
- Variable — a named box that can hold a value:
score = 0. - Condition — a question that is true or false:
score > 10. - Loop — do something several times:
repeat 5 times.
To trace a program means to walk through it line by line, writing down what every variable contains. It is the single most important skill for finding faults.
Code
total = 0
for i from 1 to 4:
if i is even:
total = total + i
The trace:
| i | even? | total |
|---|---|---|
| 1 | no | 0 |
| 2 | yes | 2 |
| 3 | no | 2 |
| 4 | yes | 6 |
Answer: 6. Draw the table every time you are unsure — the brain loves to skip steps.
Mastery means
- Traces a variable's value through a loop
- Works out which values make a condition true
Sign in to do the exercises and build your mastery up.
Sources
Leads to
Part of the goals (37)
- From blocks to Python
- The mathematics behind the models
- The developer's toolbox
- Language models in practice
- Build an agent you can trust
- Build a memory system for an agent
- Systems knowledge for AI engineers
- Evals in practice
- Train an agent with reward
- Statistics for experiments
- Build a RAG system you can trust
- Data: collect, clean, document
- An AI service in operation
- Multimodal systems
- AI safety in practice
- Training neural networks for real
- Run models more cheaply: quantisation
- AI in production
- Image classification with convolutional networks
- Build a transformer from scratch
- Train your first neural network
- Classical machine learning in practice
- Classical ML for real
- Fine-tune and run your own models
- Understand how generative AI works
- Foundations of computer science
- Deep reinforcement learning
- Fine-tune a model with LoRA
- Frontier Lab — an independent research project
- Responsible AI in practice
- Build an NLP system end to end
- Generative models in depth
- Build an AI service that survives production
- Build a voice interface
- Reproduce a paper
- Interpreting a language model
- AI, ethics and society