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.
The important terms from this lesson, grouped by topic.
17 or -4.3.14.True or False.'Q'."Hello"."18" into the integer 18.+ - * / // % **.PI — from being accidentally changed somewhere in the code."hi".upper() gives "HI".name[0:3] gives the first three characters."Hello " + name.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.
Integer — a whole number, with no decimal point.
Real (Float) — a number that can include a decimal point.
Boolean — can only ever be True or False.
Character — a single letter, digit or symbol.
String — a sequence of characters, like a word or sentence.
Each snippet is missing its operator. Work out what the output tells you, then pick the operator that belongs in the gap.
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.
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.
15 rapid-fire statements about this lesson. You've got 10 seconds per statement — answer before the bar runs out!
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).
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.if / else statement to choose which message to print.age >= 18 only works once age is an integer, not a string.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.")
Create a program that asks for two numbers and prints their sum, their quotient (integer division), and the remainder using MOD.
Tips
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).print("Sum:", num1 + num2).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)
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.name[0:3] extracts the first three characters, starting at index 0.len(name) returns how many characters are in the string, including spaces.name = input("What is your name? ")
print(name.upper())
print(name[0:3])
print(len(name))