Skip to content
Educator
KS3 Computer Science

Programming in Python

92 questions10 subtopics
Practise all 92 questions free →

What's covered

Comparison Operators10
Parameters and Return Values10
String Operations10
Arithmetic Operators9
Common Python Errors9
Data Types — Integer, Float, String, Boolean9
Functions (Subroutines)9
Lists and Indexing9
Variables and Assignment9
Input and Output8

Key facts

1

Arithmetic Operators

In Python the division operator is the forward slash /. 10 / 4 returns 2.5.

2

Common Python Errors

IndentationError means the indentation (spaces or tabs at the start of a line) is not consistent with the surrounding block.

3

Comparison Operators

Every comparison in Python returns a Boolean — True or False.

4

Data Types — Integer, Float, String, Boolean

Python's bool type stores one of two values: True or False.

5

Functions (Subroutines)

def add(a, b): return a + b — add(2, 3) returns 5.

6

Input and Output

input() does not return an integer by default — it returns a string; conversion is the programmer's job.

7

Lists and Indexing

xs.append(5) adds 5 to the end of the list xs.

8

Parameters and Return Values

def double(n): return n * 2 — double(double(3)) is double(6) = 12.

9

String Operations

'hello' + ' world' gives 'hello world' because the second string starts with a space character.

10

Variables and Assignment

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 92 questions in this topic, answers marked. Sign up to practise the full set with spaced repetition.

1Arithmetic Operators

What is 10 % 3 in Python?

  • ✓One (the remainder)
  • •Ten (the original value)
  • •Three (the quotient)
  • •Zero (no remainder)
2Common Python Errors

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
3Comparison Operators

What does 5 > 3 evaluate to?

  • •False
  • •Five
  • •Three
  • ✓True
4Data Types — Integer, Float, String, Boolean

Name two common Python data types.

  • ✓Integer and string
  • •Loop and function
  • •Syntax and logic
  • •Variable and constant
5Functions (Subroutines)

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
6Input and Output

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.

More KS3 Computer Science topics

📖 All KS3 Computer Science key terms & vocabulary →