Chapter 0 · Section 1 practice

Values, Variables, and Calculations

Work from question 1 to 10. Write your code, click Run Code, review the result, then click Submit attempt. An attempt may be wrong: reference answers become available after you submit all 10. Each Python box is independent. Submission progress is saved in this browser.

Submitted: 0 / 10

1. Show a greeting

Warm-up. Print the message Hello, Python! Use matching quotes.

Write your answer, then run it.

2. Text or a calculation?

Warm-up. Print the text 4 + 6, then print the result of adding 4 and 6. Use two lines.

Write your answer, then run it.

3. Money left

Warm-up. You have HK$80 and spend HK$18. Create money_left and print it.

Write your answer, then run it.

4. Update a score

Build your skills. Start with 12 points. Add 8, then subtract 3, reassigning points each time. Print the final value.

Write your answer, then run it.

5. Inspect numeric types

Build your skills. Print the type of quantity, the type of price, and the result of quantity * price.

Write your answer, then run it.

6. Divide in three ways

Build your skills. Print 17 / 5, 17 // 5, and 17 % 5, each on its own line.

Write your answer, then run it.

7. Use parentheses

Build your skills. Write two calculations: add 3 and 5, then multiply the result by 2; multiply 5 by 2, then add 3. Print both.

Write your answer, then run it.

8. Square and cube

Challenge. The side of a square is 6 cm. Print its area using a power. A cube has side 3 cm; print its volume using a power.

Write your answer, then run it.

9. Pack a delivery

Challenge. There are 38 pencils and each box holds 6. Print full boxes, pencils left, and the number accounted for. Use // and %.

Write your answer, then run it.

10. A small shopping budget

Challenge. You have HK$100. Buy 2 notebooks at HK$15 each and 3 pens at HK$4 each. Calculate total_spent and money_left, then print both. Define the inputs yourself.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.