← All tools

Programming Concepts – Part 1

Data types, casting, arithmetic operators, constants vs variables, and string manipulation — with key meanings, two hands-on challenges, a timed 25-question quiz with shuffled answers, a keyword matching game, a true/false speed round, and help for Task 2 at the bottom.

Key Meanings

The important terms from this lesson, grouped by topic.

Data Types

Data type
The category of value a variable holds — it decides what the computer can and can't do with it.
Integer
A whole number, with no decimal point — e.g. 17 or -4.
Real (Float)
A number that can include a decimal point — e.g. 3.14.
Boolean
A value that can only ever be True or False.
Character
A single letter, digit or symbol, usually written in quotes — e.g. 'Q'.
String
A sequence of characters — a whole word or sentence of text, e.g. "Hello".

Casting & Operators

Casting
Converting a value from one data type to another — e.g. turning the string "18" into the integer 18.
int(), float(), str()
Python functions used to cast a value to an integer, real number, or string.
Arithmetic operator
A symbol used to perform a calculation: + - * / // % **.
DIV ( // )
Integer division — divides two numbers and keeps only the whole number part, discarding any remainder.
MOD ( % )
Modulus — gives you just the remainder left over after a division.

Constants vs Variables

Variable
A named storage location whose value can change while the program is running.
Constant
A named storage location whose value is set once and cannot change afterwards.
Why use a constant?
It protects fixed values — like a tax rate or PI — from being accidentally changed somewhere in the code.

String Manipulation

.upper()
Returns a copy of a string with every character converted to uppercase — e.g. "hi".upper() gives "HI".
.lower()
Returns a copy of a string with every character converted to lowercase.
Substring / slicing
Extracting part of a string using its position — e.g. name[0:3] gives the first three characters.
len()
Returns the number of characters in a string.
Concatenation
Joining two or more strings together — e.g. "Hello " + name.

Selection & Iteration

Selection (IF / ELSE)
Lets a program choose between different paths of code depending on whether a condition is true or false.
WHILE loop
Repeats a block of code for as long as a condition stays true.
FOR loop
Repeats a block of code a set number of times, or once for each item in a list.

Match the Data Type

Drag each example (or click one, then click a definition) onto the data type it belongs to.

Match each value below to the correct data type.

"Hello World"
17
3.14
True
'Q'

Integer — a whole number, with no decimal point.

Drop here

Real (Float) — a number that can include a decimal point.

Drop here

Boolean — can only ever be True or False.

Drop here

Character — a single letter, digit or symbol.

Drop here

String — a sequence of characters, like a word or sentence.

Drop here

Pick the Right Operator

Each snippet is missing its operator. Work out what the output tells you, then pick the operator that belongs in the gap.

Test Yourself — 25 GCSE-Style Questions

Data types, casting, operators, constants, string methods — and a few code-tracing questions. A timer starts as soon as you press Start, and the answer options are shuffled into a new order every question.

Keyword Match Game

A timed matching game — match each keyword to its correct meaning. The clock starts on your first move, and the terms shuffle into a new order every time you play.

Drag each keyword (or click one, then click a meaning) onto the definition it matches.

Speed Round — True or False

15 rapid-fire statements about this lesson. You've got 10 seconds per statement — answer before the bar runs out!

Task 2 Help

Stuck on one of the three Python programs for Task 2? Expand a hint below — the example code is there to check your work against once you've had a proper go yourself, not to copy and paste (the code can't be selected or copied).

1. Data Types & Casting

Write a Python program that asks the user for their age as a string, casts it to an integer, and prints whether they are over 18.

Tips

  • input() always gives you back a string, even if the user types a number — you need to cast it with int() before comparing it.
  • Use an if / else statement to choose which message to print.
  • age >= 18 only works once age is an integer, not a string.
Show example
age_str = input("How old are you? ")
age = int(age_str)

if age >= 18:
    print("You are an adult.")
else:
    print("You are not an adult yet.")

2. Operators & Selection

Create a program that asks for two numbers and prints their sum, their quotient (integer division), and the remainder using MOD.

Tips

  • Cast both numbers with int() as soon as you read them in, so you can do maths with them.
  • + gives the sum, // gives the integer division (DIV), and % gives the remainder (MOD).
  • You can label each line of output, e.g. print("Sum:", num1 + num2).
Show example
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

print("Sum:", num1 + num2)
print("Quotient:", num1 // num2)
print("Remainder:", num1 % num2)

3. String Manipulation

Write a program that takes a user's name and prints it in uppercase, prints the first three letters, and prints the length of the name.

Tips

  • name.upper() returns an uppercase copy of the string — it doesn't change name itself.
  • Slicing with name[0:3] extracts the first three characters, starting at index 0.
  • len(name) returns how many characters are in the string, including spaces.
Show example
name = input("What is your name? ")

print(name.upper())
print(name[0:3])
print(len(name))