What's covered
Key facts
In Python the division operator is the forward slash /. 10 / 4 returns 2.5.
IndentationError means the indentation (spaces or tabs at the start of a line) is not consistent with the surrounding block.
Every comparison in Python returns a Boolean — True or False.
Python's bool type stores one of two values: True or False.
def add(a, b): return a + b — add(2, 3) returns 5.
input() does not return an integer by default — it returns a string; conversion is the programmer's job.
xs.append(5) adds 5 to the end of the list xs.
def double(n): return n * 2 — double(double(3)) is double(6) = 12.
'hello' + ' world' gives 'hello world' because the second string starts with a space character.
After x = 7, the value of x is the integer 7 — not zero, not the letter "x", not undefined.
Sample questions
A taste of the 101 questions in this topic — answers marked. Sign up to practise the full set with spaced repetition.
What is 10 % 3 in Python?
- ✓One (the remainder)
- •Ten (the original value)
- •Three (the quotient)
- •Zero (no remainder)
What is a syntax error?
- ✓Code breaks language rules
- •Program crashes only with certain inputs
- •Program runs but gives wrong output
- •Variable holds an unexpected data type
What does 5 > 3 evaluate to?
- •False
- •Five
- •Three
- ✓True
Name two common Python data types.
- ✓Integer and string
- •Loop and function
- •Syntax and logic
- •Variable and constant
Why use functions in code?
- •To increase the chance of a syntax error
- •To make the program run more slowly
- •To remove the need for any variables
- ✓To reuse code and reduce repetition
What does name = input('your name:') do in Python?
- •Counts how many letters are in 'name?'
- •Prints the word 'name?' and stops
- •Sets a variable to the string 'name?'
- ✓Shows prompt and reads user input
Try it for four weeks. Free.
One school. Unlimited classes. No card limit. No teacher limit. If your students aren't practising daily by the end of the trial, you owe us nothing.