CoursePython from Scratch to Intermediate · Module 2: Values, Types and Operators · part 17 of 75
Part 17 · Module 2: Values, Types and Operators

Lesson 4: Asking questions and printing answers

14 min read·14 Oct 2026
Module 2 · Lesson 4 · About 35 minutes · Needs: Module 2 Lessons 1 to 3 (numbers, strings, int())

The situation

Amira has her answer from Lesson 1: Ben's copy of The War of the Worlds (loan L13) is 9 days late, so he owes 180 pence. But the number 9 is written into the code. Tomorrow it will be 10, and Lena or Jonah will be standing at the counter instead.

"Can it just ask me?" she says. "I type the name and how many days late, and it tells me what they owe."

The program has to show text neatly, which is output, and take text from the person at the keyboard, which is input. By the end Amira has a late-fee calculator she can run herself.

The person types, reads Your program Python code input(): typed text comes in print(): text goes out
A program talks to a person in two directions: input() brings typed text in (amber, because you cannot be sure what will be typed) and print() sends text out (blue, your program).

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.