Chapter 1 · Section 3 practice

NumPy Arrays

Work from question 1 to 10. Edit your Python box, click Run Code, review the result, then click Submit attempt. Reference answers unlock after all ten attempts are submitted. This records completion, not correctness. Each box runs independently. Progress is saved in this browser.

Submitted: 0 / 10

1. Create an array

Warm-up. Create an array from [10, 20, 30] and print it.

Write your answer, then run it.

2. Predict multiplication

Warm-up. Print values * 2 and its array equivalent. Explain the difference in a comment.

Write your answer, then run it.

3. Read attributes

Warm-up. Create a float array from [42, 58, 28]. Print shape and dtype.

Write your answer, then run it.

4. Adjust prices

Build your skills. Add HK$2 to all prices and print the updated array.

Write your answer, then run it.

5. Compute revenues

Build your skills. Calculate corresponding count × bill revenues and their total.

Write your answer, then run it.

6. Select high prices

Build your skills. Print the mask for prices >= 50 and the selected values.

Write your answer, then run it.

7. Calculate a proportion

Build your skills. Print the fraction of observed deliveries above 40 minutes, with two decimal places.

Write your answer, then run it.

8. Choose the convention

Challenge. Print the mean and sample standard deviation to three decimals.

Write your answer, then run it.

9. Measure percentage changes

Challenge. Use slices to compute successive percentage changes for [100, 110, 99]. Print rounded percentages.

Write your answer, then run it.

10. Revenue after a discount

Challenge. Reduce bills by 10%, keep counts fixed, and calculate revenues. Print dish revenues and total to two decimals. Explain the fixed-count assumption.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.