← VCE Software Development U4O1

Choosing data types for input, storage and output

input() always returns a str, so convert it (e.g. with int) to store it as a number. Turn it back into text with str() or an f-string when you output it.

Understanding Choosing data types for input, storage and output in VCE Software Development U4O1

What it does: float() converts the str returned by input() into a number that can be stored and used in calculations. str() converts the stored int to text, so it can be joined with a string for output. Without conversion, age holds the text '25'. You must write int(input('Age: ')) to store a whole number. int() would cause a ValueError for '4.95' (and cannot hold cents). Use float() for decimal values. A bool holds True or False and can be used directly in conditions. The string 'True' is just text, and any non-empty string is treated as true. Adding two strings concatenates them. Convert with int() first to get 8.

Common mistakes: age was converted to an int on line 2, so adding the str "1" causes a TypeError. It should be age + 1, with both values numbers. total is a float, and you can't join a float to a str with +. Convert it to text with str(total) or use an f-string.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 3–79) and word search (Modules 3–114).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What data type does input() always return in Python?
int (a whole number)str (a string of text)
Matches
age = input("Age: ") next_age = age + 1
↓
input() returns a str, so age was never converted to an int. Adding 1 to a str causes a TypeError.
Applying
Meanings
Term
int(input())
Meaning
input() always returns a str, so convert it (e.g. with int) to store it as a number. Turn it back into text with str() or an f-string when you output it.
Practice
price_text = input("Price: ")
Testing
Gaps
age = (input("Enter your age: "))
Check Answer
Spots
2age = int(age)
3next_age = age + "1"

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

The 'Giraffe' badge — High Perspective, 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 data type does input() always return in Python?
A. str (a string of text) ✓
B. int (a whole number)
input() always returns text, even if the user types digits. Convert it with int() or float() if you need a number.
2. A user types 25 for their age: age = input('Age: '). What is stored in age?
A. The string '25' ✓
B. The integer 25
Without conversion, age holds the text '25'. You must write int(input('Age: ')) to store a whole number.
3. Which line stores a whole-number input so you can do arithmetic on it?
A. qty = input(int('Qty: '))
B. qty = int(input('Qty: ')) ✓
The conversion wraps around input(): int(input(...)). It converts the returned string into an int.
4. Which data type is best for storing a price such as 4.95 that was typed in by the user?
A. int(input('Price: '))
B. float(input('Price: ')) ✓
int() would cause a ValueError for '4.95' (and cannot hold cents). Use float() for decimal values.
5. Which variable should store whether a student has paid, to be used in an if statement?
A. paid = True (a bool) ✓
B. paid = 'True' (a str)
A bool holds True or False and can be used directly in conditions. The string 'True' is just text, and any non-empty string is treated as true.

Match the Pairs

age = int(input("Age: ")) → Reads the typed text from the user and converts it to an int so it can be stored as a number
print(f"Total: ${total:.2f}") → Formats a stored float as text with 2 decimal places for output
Input always arrives as a str, even when the user types digits, so it must be converted before storing as a float → price = float(input("Price: "))
A number stored as an int must be turned back into text with str() before joining it to other text for output → print("Score: " + str(score))
age = input("Age: ") next_age = age + 1 → input() returns a str, so age was never converted to an int. Adding 1 to a str causes a TypeError.
score = 42 print("Score: " + score) → An int cannot be joined to a str with +. The stored number was not converted to text for output.

Key Term

int(input())
input() always returns a str, so convert it (e.g. with int) to store it as a number. Turn it back into text with str() or an f-string when you output it.

Fill in the Blanks

1. age = int(input("Enter your age: "))
Hint: Type the function that converts the text from input() into a whole number.
2. price = float(input("Enter the price: "))
Hint: Type the function that converts the text input into a decimal number.
3. total = 12 print("Total: " + str(total))
Hint: Type the function that turns a number back into text so it can be joined to a string.
4. score = 87 print(f"Score: {score}%")
Hint: Type the single letter placed before the opening quote to make a formatted string.
5. name = input("Name: ") print(type(name) == str)
Hint: Type the data type that input() always returns, whatever the user types.

Spot the Error

Question 1
A age = input("Age: ")
B age = int(age)
C next_age = age + "1"
D print(f"Next year: {next_age}")
Line C — age was converted to an int on line 2, so adding the str "1" causes a TypeError. It should be age + 1, with both values numbers.
Question 2
A cost = float(input("Cost: "))
B qty = int(input("Qty: "))
C total = cost * qty
D print("Total: " + total)
Line D — total is a float, and you can't join a float to a str with +. Convert it to text with str(total) or use an f-string.
Question 3
A score = input("Score: ")
B score = str(score)
C if score >= 50:
D print("Pass")
Line B — str() keeps the score as text, so score >= 50 compares a str to an int and causes a TypeError. It should be int(score) to store the score as a number.
Question 4
A m = input("Metres: ")
B cm = m * 100
C print(f"{cm} cm")
Line A — input() always returns a str, so m * 100 would repeat the text 100 times instead of calculating. It should be wrapped in float(): m = float(input("Metres: ")).
Question 5
A name = input("Name: ")
B mark = int(input("Mark: "))
C print(name + " got " + mark)
Line C — mark is an int, and + cannot join a str and an int, so this causes a TypeError. Use an f-string such as f"{name} got {mark}" or str(mark).

Student with a class code? Join your class →