COURSE · 1 chapter · 20 lessons

Python

Learn how programming thinks, with fewer symbols in the way

Pick either this or the JavaScript course — you only need one. Chapter 1, "The basics of syntax", is ready, and the rest is being added in order.

Read about this chapter

Show text and numbers

  1. 01Your first PythonUse print to put what you wrote up on the screen.7 slides · 13 exercisesGo to the exercises
  2. 02Numbers and mathsLet Python do the sums. A number is written without quotes, unlike text.6 slides · 13 exercisesGo to the exercises
  3. 03Dividing, and what is left overThere are three symbols for dividing. We will see why a tidy answer still comes out as a decimal.6 slides · 13 exercisesGo to the exercises
  4. 04The order things happen inTimes first, brackets even sooner. Here is how to make Python work things out the way you meant.6 slides · 13 exercisesGo to the exercises
  5. 05Joining text together+ is not only for numbers. It works on text too — but mix in a number and Python tells you off.6 slides · 13 exercisesGo to the exercises
  6. 06Writing commentsEverything after # is ignored. Leave a note for the you of next week.6 slides · 13 exercisesGo to the exercises

Give a value a name

  1. 07Making a variableGive a value a name, and you can call it back up as many times as you like.6 slides · 13 exercisesGo to the exercises
  2. 08Why bother with variablesIt all runs without them, so why use them? Put the two side by side and see.6 slides · 13 exercisesGo to the exercises
  3. 09Changing what is insideWhat is in a variable can be swapped out later. We will see why x = x + 1 makes sense.6 slides · 13 exercisesGo to the exercises
  4. 10The shorter way to write itx = x + 1 can be written x += 1. It comes up so often that it is worth knowing.6 slides · 13 exercisesGo to the exercises
  5. 11Dropping values into a sentenceWrite {} inside f"..." and the contents of a variable land there. It is the way you will write most often.6 slides · 13 exercisesGo to the exercises
  6. 12Changing what kind of value it isThe text "10" and the number 10 are different things. Here are the tools for going between them.6 slides · 13 exercisesGo to the exercises

The rules of indentation

  1. 13The rules of indentingIn Python the spaces at the start of a line mean something. Get this now and you will not trip later.6 slides · 13 exercisesGo to the exercises

Branch on a condition

  1. 14Branching on a conditionWrite an if and your program has an opinion for the first time.6 slides · 13 exercisesGo to the exercises
  2. 15Comparing bigger and smallerA comparison answers True or False. Let us open up a condition and look inside.6 slides · 13 exercisesGo to the exercises
  3. 16Asking whether things are the same= puts in, == asks. This is the one beginners muddle most.6 slides · 13 exercisesGo to the exercises
  4. 17The other roadWrite an else and you have somewhere to go when the condition does not hold.6 slides · 13 exercisesGo to the exercises
  5. 18Splitting it more waysLine up some elifs and you can have three roads, or four, or as many as you need.6 slides · 13 exercisesGo to the exercises
  6. 19Combining conditionsIn Python it is and, not &&. Being able to read it out loud is very Python.6 slides · 13 exercisesGo to the exercises
  7. 20When there is nothing thereNone is the value for "nothing at all". We will also hand values straight to a condition.6 slides · 13 exercisesGo to the exercises