Quarry School

Read a reply from the keyboard

Subject: Computing
Level 1 · FoundationsAbout 4 min read7 new terms
How this was estimated

Programmatic estimate. Rung levels, worked steps, prerequisites, terms and sentence length contribute to this level. It describes the lesson, not your ability.

Reading counts the whole lesson, including folded explanations, at 180 words a minute. Practice allows two minutes per item. These are planning assumptions; take the time you need.

AI estimate unavailable.

Path to here

Open the unit’s lesson list to follow the lesson order.

    Quick review (2 minutes)

    In plain words

    Imagine a school fair with a badge marked 04 and four spare badges on a tray.

    Rule

    Keep the reply as text for a badge code, where every character matters. For a count written in digits, convert the reply with int(reply) before adding to it.

    Step

    1. Type the Python source, the lines of code shown below, in your editor. Keep the blank line after reply = input() and save the file.

    2. Run the saved file with Python 3.13. The input() call has empty parentheses, so it waits for your reply without displaying a message asking for it. Type the two digits 04 where the program is running and press Enter.

    3. Compare the two lines the program prints with the expected output. The Shell can show your typed reply above those lines. If you’re working on paper, follow the code one line at a time and write down what each print() displays.

    Trap

    A reply can look like a number and still be text. Writing reply + 1 skips the conversion. Use int(reply) + 1 for the count. For this version, enter a whole number written in digits, such as 04 or 8. The word four is outside the form that int() can convert here.

    1 In plain words

    Imagine a school fair with a badge marked 04 and four spare badges on a tray. If you copy the badge code onto a list, you write both digits. If someone brings one more spare badge, the tray holds five.

    The line you give the program is its input. Read reply = input() as “read one line of text and save it under the name reply.” Remember that the reply is text. To use the digits as a number, look up int(), which turns digit text like 04 into a whole number.

    2 Picture it

    reply0404int(reply)4 + 1 = 5

    Type 04 and press Enter. Keep both characters for a badge. To use the reply as a count, convert it to 4 and add one to get 5.

    One reply, two uses

    3 Why

    Python calls a piece of text a string. When you type 04 and press Enter, input() returns a string, which means it gives text back to the program. The reply has two characters, 0 and 4. input() leaves out the line break at the end.

    Python calls a whole number like 4 an integer. To convert is to change to a different form. In int(reply), the name inside the parentheses tells int() which text to convert. It reads 04 as the integer 4, and then + 1 adds one.

    The program’s output is what it displays here. In this code, each print() displays one value on its own line. print(reply) displays the saved text, including the zero at the front. print(int(reply) + 1) displays the result of adding one to the count.

    4 The rule

    Keep the reply as text for a badge code, where every character matters.

    For a count written in digits, convert the reply with int(reply) before adding to it.

    5 How

    1. Type the Python source, the lines of code shown below, in your editor. Keep the blank line after reply = input() and save the file.
    2. Run the saved file with Python 3.13. The input() call has empty parentheses, so it waits for your reply without displaying a message asking for it. Type the two digits 04 where the program is running and press Enter.
    3. Compare the two lines the program prints with the expected output. The Shell can show your typed reply above those lines. If you’re working on paper, follow the code one line at a time and write down what each print() displays.

    6 Worked example

    One reply for a badge and a count

    Python code
    reply = input()
    
    print(reply)
    print(int(reply) + 1)
    

    Prompt

    Type 04 in the Shell and press Enter.

    Standard input

    04
    

    Standard output

    04
    5
    

    The first line of output keeps the two badge characters. To check the second line on paper, draw four strokes and add one.

    Trace

    How the reply becomes two output lines
    InstructionExpression valueOutputExplanation
    reply = input()text 04—The saved reply has two characters.
    print(reply)text 0404Print writes both characters in their original order.
    print(int(reply) + 1)number 55Integer conversion gives 4. Adding one gives 5.

    7 The trap

    A reply can look like a number and still be text. Writing reply + 1 skips the conversion. Use int(reply) + 1 for the count. For this version, enter a whole number written in digits, such as 04 or 8. The word four is outside the form that int() can convert here.

    Quick checks

    Quick check 1 of 2

    A badge must show the typed code 04 exactly. What should the program print to keep both characters, reply or int(reply)?

    Show the steps and the answer
    Answer

    Print reply. The badge shows 04.

    Why: The saved text contains both characters, including the zero at the front.

    Source: Python Software Foundation, Python 3.13 Built-in Functions (input)

    Quick check 2 of 2

    You run the same program and type 08. What appears on the first and second output lines?

    Show the steps and the answer
    Answer

    The first line is 08. The second line is 9.

    Why: The first line prints the saved text. For the second, int(reply) gives 8, then adding 1 gives 9.

    Source: Python Software Foundation, Python 3.13 Built-in Functions (int)

    Sources

    1. Python 3.13 Built-in Functions (input). Python Software Foundation. Python Software Foundation License Version 2. Read 25 Nov 2026.
    2. Python 3.13 Built-in Functions (int). Python Software Foundation. Python Software Foundation License Version 2. Read 25 Nov 2026.