Converting types with int() and float()
input() gives text, so int() wraps it to turn the typed text into a whole number you can calculate with. Use float() for decimals. str() turns a number back into text.
Understanding Converting types with int() and float() in Years 7–8 Creating Digital Solutions
What it does: A number cannot be joined to a string with + until str() changes it into text. input() always gives back a string, even when the user types digits. float() keeps decimals. int() is for whole numbers, and int('4.50') causes an error. age is a string, so it must be converted with int(age) before you can add 1. After int() turns the text into numbers, + adds them. Joining '7' + '3' as strings would give '73'. int() can't convert text with a decimal point. Use float() for decimals. The fix is age = int(input("Age: ")). Then age + 1 works because age is a whole number.
Common mistakes: input() gives back text, so age + 1 would crash. Wrap it in int(): age = int(input("Age: ")). str() keeps the value as text, so score + 10 would crash. Use int() to turn the typed text into a whole number.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 50–125) and word search (Modules 3–125).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
int(input())Fill in the Blanks
Spot the Error
Student with a class code? Join your class →