← Python

Type Conversion

int(), float(), and str() convert a value from one type to another

What it does: The f prefix and curly braces embed the variable value into the string. You can put expressions inside {} and Python evaluates them. {name} is replaced by the value stored in name. The {} placeholder is replaced by the variable's value. f before the quote means 'format string' — f"...". {city} is replaced by the value 'Melbourne'. Only the characters you write and the variable's value appear — no extra spaces. {score} is replaced by 100.

Common mistakes: Line 2 is missing f. Should be: message = f"Hello {name}". Line 2 is missing curly braces. Should be: f"I am {age} years old".

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
After name = "Alice", what is f"Hi {name}"?
Hi AliceHi {name}
Matches
❌ name = 'Bob' print('Hi {name}')
Error: Missing f prefix
Applying
Meanings
Term
name = "Alice"
Meaning
Assigns the string Alice to the variable name.
Practice
name = "Alice"
Testing
Gaps
greeting = "Hello {name}"
Check Answer
Spots
1name = "Alice"
2message = "Hello {name}"

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Golden Eagle' badge — High Flyer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. After name = "Alice", what is f"Hi {name}"?
A. Hi Alice ✓
B. Hi {name}
{name} is replaced by the value stored in name
2. After age = 15, what is f"I am {age}"?
A. I am {age}
B. I am 15 ✓
The {} placeholder is replaced by the variable's value
3. What letter starts an f-string?
A. f ✓
B. s
f before the quote means 'format string' — f"..."
4. Where do variables go in f-strings?
A. After +
B. Inside {} ✓
Curly braces {} mark where a variable value will be inserted
5. After city = "Melbourne", what is f"Welcome to {city}"?
A. Welcome to Melbourne ✓
B. Welcome to {city}
{city} is replaced by the value 'Melbourne'

Match the Pairs

name = 'Bob' print('Hi {name}') Error: Missing f prefix
age = 10 f'Age: {age'} Invalid: Unclosed brace
x = 5 f'Value: {x}' Valid: f-string syntax
f'{2 + 2}' Ok: Expressions inside {}
name = 'Ali' print(f'Hi {name}!') Output: Hi Ali!
n = 7 print(f'{n} * 2 = {n*2}') Output: 7 * 2 = 14

Key Term

name = "Alice"
Assigns the string Alice to the variable name.~~f"Hello {name}"

Fill in the Blanks

1. greeting = f"Hello {name}"
2. age = 12 message = f"I am {age} years old"
3. city = "Sydney" text = f"Welcome to {city}"
4. score = 85 result = f"Your score: {score}"
5. first = "Jo" last = "Li" full = f"{first} {last}"

Spot the Error

Question 1
A name = "Alice"
B message = "Hello {name}"
C print(message)
Line B — Line 2 is missing f. Should be: message = f"Hello {name}"
Question 2
A age = 15
B info = f"I am age years old"
C print(info)
Line B — Line 2 is missing curly braces. Should be: f"I am {age} years old"
Question 3
A city = "Melbourne"
B text = f"Welcome to [city]"
C print(text)
Line B — Line 2 uses [ ] instead of { }. Should be: f"Welcome to {city}"
Question 4
A first = "Bob"
B last = "Smith"
C name = f"{first} {last}"
D greeting = f"Hello (name)"
E print(greeting)
Line D — Line 4 uses (name) instead of {name}. Should be: f"Hello {name}"
Question 5
A score = 100
B message = f"Score: {score}"
C age = 15
D info = "Age: {age}"
E print(info)
Line D — Line 4 is missing f. Should be: info = f"Age: {age}"
For Teachers

Create a free class, add this module to a journey, and track who's stuck.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?