← Python

F-String Formatting

An f-string embeds variable values directly inside a string using the f"...{variable}..." syntax

What it does: int() converts a numeric string to an integer. str() converts a number to a string — useful for concatenation. int() truncates — it cuts off the decimal, it does not round. str() always produces a string — not a float. float() adds a decimal point — the integer 5 becomes 5.0. Python can't add a string and a number — use int('5') + 3 instead. int('10') converts '10' to the number 10, then 10 + 5 = 15. str(5) converts 5 to a string — type() then reports it as 'str'.

Common mistakes: Line 2 should use int() not str(). Use: number = int(text). Line 2 can't add string + int. Convert first: next_age = int(age) + 1.

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
What does int("5") return?
5"5"
Matches
❌ int('hello')
Error: Cannot convert to int
Applying
Meanings
Term
int("5")
Meaning
Converts the string "5" to the integer 5.
Practice
cm = int("42")
Testing
Gaps
number = ("42")
Check Answer
Spots
1text = "42"
2number = str(text)

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

The 'Gazelle' badge — Tuple Sprinter, 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. What does int("5") return?
A. 5 ✓
B. "5"
int() converts a string of digits into an actual integer
2. What does str(42) return?
A. 42
B. "42" ✓
str() converts a number into a string — strings have quote marks
3. What does float("3.14") return?
A. 3.14 ✓
B. "3.14"
float() converts a string like '3.14' into the floating-point number 3.14
4. What does int(3.9) return?
A. 4
B. 3 ✓
int() truncates — it cuts off the decimal, it does not round
5. What does str(100) convert 100 to?
A. A string ✓
B. A float
str() always produces a string — not a float

Match the Pairs

int('hello') Error: Cannot convert to int
x = '5' print(x + 3) Error: str + int not allowed
int('42') Valid: Returns 42
str(100) Ok: Returns '100'
print(int(3.9)) Output: 3
print(float('2.5')) Output: 2.5

Key Term

int("5")
Converts the string "5" to the integer 5.~~float("3.14")

Fill in the Blanks

1. number = int("42")
2. text = str(100)
3. decimal = float("300")
4. year = input() year = int(year)
5. score = 95 result = str(score) print(result)

Spot the Error

Question 1
A text = "42"
B number = str(text)
C print(number + 1)
Line B — Line 2 should use int() not str(). Use: number = int(text)
Question 2
A age = input("Enter age: ")
B next_age = age + 1
C print(next_age)
Line B — Line 2 can't add string + int. Convert first: next_age = int(age) + 1
Question 3
A score = 95
B message = "Score: " + score
C print(message)
Line B — Line 2 can't join string + int. Use: message = "Score: " + str(score)
Question 4
A value = "3.14"
B decimal = Int(value)
C print(decimal)
Line B — Line 2 uses Int() with capital I. Python is case-sensitive. Use: int(value)
Question 5
A int("7")
B num = "7"
C print(num + 3)
Line A — Converts but doesn't save the result. Use: num = int(num)
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?