← ACARA Digital Technologies Years 9–10

Testing a program that uses input()

Pauses a program so you can type a test value; it returns text. Test by typing each planned input in order, then compare the printed output with the expected result.

Understanding Testing a program that uses input() in ACARA Digital Technologies Years 9–10

What it does: The test case lists the inputs in order (4 first, then 5) so each run can be repeated and compared with the expected output of 20. int() converts the text returned by input() into a whole number so the program can calculate with the test value. Because input() returns text, + joins the strings "4" and "4" to make "44". Your expected output must allow for this.

Common mistakes: input() returns text, so a + b joins the strings. Typing 2 then 3 prints 23 instead of the expected 5. Convert with int(a) + int(b). passed has no quotes, so Python looks for a variable called passed and gives a NameError. The text must be in quotes: "passed".

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 591–622) and word search (Modules 536–622).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Your test plan lists inputs 4 then 6 for a program that calls input() twice. What should you do when you run it?
Type 6 first, because the last input is the most importantType 4 at the first prompt, then 6 at the second prompt
Matches
a = input("A: ") b = input("B: ") print(a + b) # Test: type 3 and 4, expect 7
↓
input() returns text, so "3" + "4" joins the strings and prints 34, not 7. The actual output will not match the expected result.
Applying
Meanings
Term
input()
Meaning
Pauses a program so you can type a test value; it returns text. Test by typing each planned input in order, then compare the printed output with the expected result.
Practice
age = int(input("Age: "))
Testing
Gaps
age = ("Enter your age: ")
Check Answer
Spots
2b = input("Second: ")
3print(a + b)

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

The 'Leopard' badge — Savannah Perfectionist, 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. Your test plan lists inputs 4 then 6 for a program that calls input() twice. What should you do when you run it?
A. Type 6 first, because the last input is the most important
B. Type 4 at the first prompt, then 6 at the second prompt ✓
Type the planned inputs in the order the program asks for them. The first input() gets the first planned value, the second input() gets the second.
2. A test case says: input 5, expected output 10. Which step is part of testing a program that uses input()?
A. Run it, type 5 when asked, then compare the printed output with 10 ✓
B. Run it, type any number you like, then decide if the output looks right
Testing means using the planned input and comparing the output with the expected result. Random inputs cannot be checked against a plan.
3. You test the same program twice. Which is the better way to repeat the test?
A. Type exactly the same planned inputs on each run ✓
B. Type different inputs each run so it feels fresh
Using the same inputs each run makes the test repeatable. If the result changes, you know the code changed, not the test.
4. After age = input("Age: "), what type of value is stored in age when you type 15?
A. Text (a string) "15" ✓
B. A whole number 15
input() always returns text. Use int(input()) if you need a number you can do maths with.
5. The code is x = input("Number: ") then print(x + x). You type 4. What is printed?
A. 8
B. 44 ✓
Because input() returns text, + joins the strings "4" and "4" to make "44". Your expected output must allow for this.

Match the Pairs

age = input("Age: ") → Pauses the program so the tester can type a test value. Whatever is typed is stored in age as text.
print("Total:", total) → Shows the actual output, which the tester compares with the expected result written in the test plan.
When testing, type the planned inputs in the order the program asks for them, and use the same inputs on every run. → Test 1: type 4, then 5, then check the output is 20
input() returns text, so a typed 7 arrives as the string "7" and must be converted before doing maths. → num = int(input("Number: "))
a = input("A: ") b = input("B: ") print(a + b) # Test: type 3 and 4, expect 7 → input() returns text, so "3" + "4" joins the strings and prints 34, not 7. The actual output will not match the expected result.
# Test plan: type 10, then 2 name = input("Name: ") age = input("Age: ") # Tester types 2, then 10 → The tester typed the inputs in a different order from the plan, so the values went into the wrong variables and the test is not repeatable.

Key Term

input()
Pauses a program so you can type a test value; it returns text. Test by typing each planned input in order, then compare the printed output with the expected result.

Fill in the Blanks

1. age = input("Enter your age: ") print(age)
Hint: Type the function that pauses the program so the tester can type a planned test value.
2. n = int(input("Number: ")) print(n * 2)
Hint: Type the function that converts the typed text into a whole number so the maths works.
3. a = input("First: ") b = input("Second: ") print(int(a) + int(b))
Hint: Type the conversion function so typed test inputs are added as numbers, not joined as text.
4. x = input("Enter a number: ") print(type(x))
Hint: Type the function that reports the data type of a value, showing what input() gives back.
5. actual = "Hi " + input("Name: ") print(actual == "Hi Sam")
Hint: Type the operator that checks whether the actual output equals the expected result.

Spot the Error

Question 1
A a = input("First: ")
B b = input("Second: ")
C print(a + b)
Line C — input() returns text, so a + b joins the strings. Typing 2 then 3 prints 23 instead of the expected 5. Convert with int(a) + int(b).
Question 2
A name = input("Name: ")
B score = int(input("Score: "))
C if score >= 50:
D print(name, passed)
Line D — passed has no quotes, so Python looks for a variable called passed and gives a NameError. The text must be in quotes: "passed".
Question 3
A print("Enter a number")
B n = int(input)
C print(n * 2)
Line B — input needs brackets to be called. Without () the program never pauses for the test value. It should be int(input()).
Question 4
A p = float(input("Price: "))
B q = int(input("Qty: "))
C total = p + q
D print("Total:", total)
Line C — The total should multiply price by quantity. Typing 2.5 then 4 should print 10.0 but the broken line prints 6.5. It should be p * q.
Question 5
A guess = int(input("Guess: "))
B secret = 7
C if guess = secret:
D print("Correct")
Line C — A single = assigns a value and is a syntax error in a condition. To compare the typed test input with the secret, use ==.

Student with a class code? Join your class →