──────────────────────────────────────

6. The Club Pass Desk · Price a Ticket Order

Convert a line of text into a number before doing arithmetic.

Lesson files · lessons/input-and-decisions/numbers-from-input

Before you start
- Read one line with input().
- Multiply a count by a fixed amount.

By the end
- Use int(input()) to read a whole number for arithmetic.
- Explain why multiplying the text "3" gives a different result from multiplying the number 3.

Where you can use it
Work out the cost of an activity order. Read the number of items as a whole number so you can multiply it by the price.

When you type 3, input() gives Python the text "3". In int(input()), Python reads a line first and then int() converts it to a whole number. The number 3 times 5 gives 15. The text "3" times 5 gives "33333".

Try a whole number in Program input. If you enter the word three, the conversion raises a ValueError. In the debugging module you will give the user a helpful response when that happens.

Predict
What does the example print for 0?
- 5
- 0

Worked example (example.py)

count = int(input())
print(count * 5)


Example input
3

Example result
15

Read the number of tickets and print the total at 12 rand each. For three, print Total: R36.

Starter program (starter.py)

count = int(input())
print(count * 5)


Starter input
3

Hint
Make count an int first. Then put the calculated price after the R in an f-string.

Case 1. Try the sample
Input
3
Expected output
Total: R36

Case 2. Zero tickets
Input
0
Expected output
Total: R0

Stretch
Read a ticket price on a second line and use both numbers in your total.

Reflect
How is the text "3" different from the number 3 in a multiplication?

Check your prediction
0 The number read into count is multiplied by the ticket price.
