GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.34

Computational thinking and programming

Choose and import libraries responsibly

Read a little. Try the workbook. Check your answers. Choose one section below to get started.

Topic 1.34 · Choose and import libraries responsibly8 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Choose and import libraries responsibly

A library groups reusable code. Use the correct import and check the official documentation for names, parameters and results. A function name or an unrelated web example is not a complete specification.

Today’s two goals
  • Identify benefits, limitations and an import statement; distinguish standard-library examples from external packages.
  • Explain my method and support it with a labelled trace, example or test record.
Original PaxaKids illustration for Choose and import libraries responsibly. Use the supplied program and data models for precise workbook facts.
An original PaxaKids workbook scene. Use the supplied programs and data for precise workbook facts.

Work through an example

After import math, math.sqrt(81) returns 9.0. The module prefix identifies the library. Check the allowed inputs instead of assuming every number or text value is accepted.

Try before your workbook

With import math, what library-qualified call calculates the square root of 16?

Explore the clues

Tap one card to find out more.

Understand the idea

A library groups reusable code. Use the correct import and check the official documentation for names, parameters and results. A function name or an unrelated web example is not a complete specification.

Concept to practise: Choose and import libraries responsibly.

Work through an example

After import math, math.sqrt(81) returns 9.0. The module prefix identifies the library. Check the allowed inputs instead of assuming every number or text value is accepted.

Try before your workbook

With import math, what library-qualified call calculates the square root of 16?

Check my readiness thinking

math.sqrt(16), which returns 4.0. Use the documented function name and retain the module prefix for this import style.

Your original programs and learning models

These original PaxaKids program and data models support your workbook. Some examples deliberately contain faults to investigate. Follow their headings and preserve exact code case, punctuation and order. Traces and supplied records are not claims of physical testing.

Choose reusable code for a clear purpose

Libraries can speed up development and give access to well-tested features. You still need to check that a feature suits your data and that your program uses it correctly.

Choose an established source, read its documentation and test relevant cases. External packages need to be available in the environment; importing one does not download it. This workbook’s executable examples use the Python standard library.

Distinguish standard modules from external packages

Write Standard or External. Standard means part of Python’s standard library; External means supplied separately and possibly already available. Purposes follow official documentation for math, random, pandas, NumPy and TensorFlow.
Distinguish standard modules from external packages — original model
Library/moduleTypical purposeCategory
mathMathematical functions and constants{'clue': 'Category', 'prompt': 'Category of math', 'answers': ['Standard']}
randomPseudo-random numbers and selections{'clue': 'Category', 'prompt': 'Category of random', 'answers': ['Standard']}
pandasAnalyse and manipulate tabular data{'clue': 'Category', 'prompt': 'Category of pandas', 'answers': ['External']}
NumPy (numpy)Array-based numerical computing{'clue': 'Category', 'prompt': 'Category of NumPy (numpy)', 'answers': ['External']}
TensorFlow (tensorflow)Build and use machine-learning models{'clue': 'Category', 'prompt': 'Category of TensorFlow (tensorflow)', 'answers': ['External']}

Import a module before using its features

import math makes the module name available. The dot in math.ceil identifies a feature in that module. Parentheses supply the argument 6.2, and the returned integer is stored in rounded before printing. The Python modules guide explains this pattern.
Original Paxa standard-library example
import math
rounded = math.ceil(6.2)
print("Rounded up:", rounded)

Match a task to the stated library purpose

Choose from math, random, pandas and NumPy. Use the page 2 purposes. These are clear classroom examples of specialisms; other libraries may also offer related features.
Match a task to the stated library purpose — original model
TaskSuitable named library
Work with a labelled table of club attendance{'clue': 'Name or category', 'prompt': 'Library for labelled attendance table', 'answers': ['pandas']}
Perform numerical operations on a large array{'clue': 'Library name', 'prompt': 'Library for array operations', 'answers': ['NumPy', 'numpy']}
Choose a pseudo-random game outcome{'clue': 'Name or category', 'prompt': 'Library for pseudo-random game outcome', 'answers': ['random']}
Use a mathematical ceiling function{'clue': 'Name or category', 'prompt': 'Library for ceiling function', 'answers': ['math']}

Review evidence, limits and honest reuse

Prefer the project’s official documentation for its purpose, supported Python versions, installation requirements and examples. Check the package’s exact identity and classroom approval before any optional installation. No external installation is needed for these tasks.

Test the outcomes your program needs, even if the feature has been tested by its authors. Acknowledge borrowed code or documentation and explain your own changes and reasoning. An old count of available libraries is not a current fact.

Use source cards for two additional libraries

These two standard-library examples go beyond the five names on page 2. The statistics guide describes numeric summaries such as an arithmetic mean. The calendar guide describes calendar-related work; isleap(year) returns True for a leap year and False otherwise. Here [2, 4, 6] supplies three numeric data values.
Use source cards for two additional libraries — original model
Source cardPurpose and example feature
statisticsNumeric summaries; mean(data) calculates the arithmetic mean.
calendarCalendar operations; isleap(year) tests the leap-year property.
Original Paxa research starter examples
import statistics
import calendar
print("Mean:", statistics.mean([2, 4, 6]))
print("Leap year:", calendar.isleap(2032))

Files for this activity

Use these original PaxaKids practice files with the matching workbook. Work on a local copy in the appropriate editor. Some examples deliberately contain faults to investigate; a downloaded file is not a completed practical test.

Paxa the Fox

Try one step with Paxa!

Trace code in the stated order and preserve exact spelling and case. Use fictional data. Label a prediction, paper trace, simulator run and physical-device test separately; an unperformed test stays Pending. Save personal responses before leaving.

Our Unit 1 learning path
  1. Lesson 1.1: Recall algorithms and representations
  2. Lesson 1.2: Purpose and conventions of pseudocode
  3. Lesson 1.3: Input, output and strings
  4. Lesson 1.4: Identifiers and assignment
  5. Lesson 1.5: Arithmetic and translation
  6. Lesson 1.6: Trace and review a sequence
  7. Lesson 1.7: Conditions and two-way flow
  8. Lesson 1.8: IF THEN and indentation
  9. Lesson 1.9: IF THEN ELSE and decision diagrams
  10. Lesson 1.10: Ordered ELSEIF and fallback ELSE
  11. Lesson 1.11: Match flowchart and pseudocode branches
  12. Lesson 1.12: AND, OR and NOT
  13. Lesson 1.13: Grouping, precedence and review
  14. Lesson 1.14: Why software searches
  15. Lesson 1.15: A successful linear search
  16. Lesson 1.16: An unsuccessful search and termination
  17. Lesson 1.17: Practise and communicate the search
  18. Lesson 1.18: Translate conditions into Python
  19. Lesson 1.19: One-branch IF programs
  20. Lesson 1.20: Two-way IF ELSE programs
  21. Lesson 1.21: Ordered ELIF choices
  22. Lesson 1.22: Ranges and independent decisions
  23. Lesson 1.23: Boolean operators in Python
  24. Lesson 1.24: Design and test recommendations
  25. Lesson 1.25: Trace, debug and reflect
  26. Lesson 1.26: Choose data types and recognise Boolean literals
  27. Lesson 1.27: Set and use Boolean flags
  28. Lesson 1.28: Explain and identify constants
  29. Lesson 1.29: Express constants in three algorithm forms
  30. Lesson 1.30: Use a fixed factor in a calculation
  31. Lesson 1.31: Cast to Boolean and validate an empty response
  32. Lesson 1.32: Recall calls and trace return values
  33. Lesson 1.33: Supply parameters and reuse library code
  34. Lesson 1.34: Choose and import libraries responsibly
  35. Lesson 1.35: Round with floor and ceiling
  36. Lesson 1.36: Use pi and investigate another mathematical feature
  37. Lesson 1.37: Generate random choices within bounds
  38. Lesson 1.38: Investigate random real values and review library use
  39. Lesson 1.39: Retrieve test tables and predict selection outcomes
  40. Lesson 1.40: Decompose everyday problems
  41. Lesson 1.41: Decompose programs and organise shared work
  42. Lesson 1.42: Develop through repeated build/test cycles
  43. Lesson 1.43: Predict and verify algorithm outcomes
  44. Lesson 1.44: Choose representative and boundary tests
  45. Lesson 1.45: Build, execute and review a test plan
  46. Lesson 1.46: Recall physical inputs and compare transmission media
  47. Lesson 1.47: Configure a radio group and agree a message scheme
  48. Lesson 1.48: Send and receive numbers and strings
  49. Lesson 1.49: Trace numeric message sequences
  50. Lesson 1.50: Transmit text and use received data in conditions
  51. Lesson 1.51: Diagnose and extend a message protocol
  52. Lesson 1.52: Review communication and evidence of testing
  53. Lesson 1.53: Project 1: Adventure story
  54. Lesson 1.54: Project 2: Fire, Water, Earth
  55. Lesson 1.55: Check your progress 1
For grown-ups: using this lesson

Your answers are checked in your browser. Open responses need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

Read one explanation, discuss the model and try the readiness check before the workbook. Choose “Mark lesson finished” when ready. Optional account progress saves lesson position and completion across devices; save personal responses before leaving.

2. Fill in your workbook

Read the teaching and complete workbook instructions. Choose, write or draw; Answer list offers larger controls. Trace code precisely and distinguish predictions from actual tests. Review designs, explanations and drawings with a grown-up.

Choose and import libraries responsibly8 student pages · original artwork

Opening your PDF…

Swipe sideways across the worksheet on a small screen, or use “Answer list” for larger controls.

TAKE YOUR PRACTICE OFFLINE

3. Download the student worksheet

All 8 original A4 student pages, ready for pencil-and-paper practice. Choose Review Answers to check your work on this webpage.

Student worksheet only · PDF · 8.5 MiB · No answer key included

Download worksheet PDF ↓

TRY FIRST, THEN CHECK TOGETHER

Download the student worksheet →

4. Answers & guidance

Finished your try? Open the guide and compare one worksheet at a time. Your own words may be different and still explain the right idea.

Shown on this webpage only. There is no answer-key download, and this guide is left out when printing the page.

Show answers for all 8 worksheets

Worksheet 1

  1. Question 1: What is a benefit of an appropriate library? reusing existing work can save development time
  2. Question 2: What should happen before using an unfamiliar package? check its source, purpose and documentation

Worksheet 2

  1. Question 3: Category of math Standard
  2. Question 4: Category of random Standard
  3. Question 5: Category of pandas External
  4. Question 6: Category of NumPy (numpy) External
  5. Question 7: Category of TensorFlow (tensorflow) External

Worksheet 3

  1. Question 8: Which complete line imports the module? import math
  2. Question 9: What is the full printed line? Rounded up: 7
  3. Question 10: Does this import statement install an external package? no, it imports an available module

Worksheet 4

  1. Question 11: Library for labelled attendance table pandas
  2. Question 12: Library for array operations NumPy / numpy
  3. Question 13: Library for pseudo-random game outcome random
  4. Question 14: Library for ceiling function math

Worksheet 5

  1. Question 15: Which is the strongest evidence for a package’s supported usage? its current official documentation and relevant tests
  2. Question 16: Which statement is accurate? library reuse still requires correct arguments and program tests

Worksheet 6

  1. Question 17: What number follows Mean: in the example output? 4
  2. Question 18: What Boolean follows Leap year: for 2032? True

Worksheet 7

  1. Question 19: Compare two fictional requirements: round a measurement upward with a mathematical ceiling, and analyse a labelled club-attendance table. Choose a suitable library for each using page 2, explain its purpose and state whether it is Standard or External. For the ceiling requirement, use the complete page 3 program and identify the import, call, argument, returned value and stored variable. Predict and check the output or mark actual execution Pending. Explain why the external data package may need separate availability checks and why both programs still require testing. Cite official sources and keep your evidence. math for mathematical ceiling, Standard; pandas for labelled/tabular attendance analysis, External. Appropriate alternatives accepted only with documented match and correct standard/external classification. import math; call math.ceil(6.2); argument 6.2; returned integer 7 stored in rounded; exact output Rounded up: 7. Import makes an available module accessible and does not install an external package. Source identity, environment compatibility and classroom approval checked before any optional installation, none required here. Test intended cases even with established libraries; actual/Pending and cited documentation/code/evidence. No invented pandas installation or analysis claimed. Grown-up review; personal evidence is required.

Worksheet 8

  1. Question 20: Use a search engine, if available, to find two Python libraries beyond the five listed on page 2. Start with statistics and calendar from page 6 or choose other appropriate examples. Read each project’s official documentation, then record its exact name, purpose, Standard/External category, source title, URL and date checked in your own words. As a challenge, identify one function in each, describing an example argument and returned value. Share findings with a partner if available or review individually; mark unperformed search, exchange or execution Pending. Keep your notes and explain your contribution and one next step. Two additional names outside math/random/pandas/NumPy/TensorFlow, distinct purposes, accurate Standard/External classification, primary source title/URL/date and original paraphrases. Starter statistics/ calendar both Standard; statistics.mean([2,4,6]) returns 4, calendar.isleap(2032) returns True; challenge distinguishes arguments and returns. Other documented appropriate libraries/functions accepted. Actual independent search and review/partner evidence or truthful provided-card reading with search/exchange Pending; no fabricated online visit, installed package or code execution. Notes explain own work, support and next step; no numeric grading. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Choose and import libraries responsibly with this free Grade 8 Computing lesson. Read one idea together, try the fillable workbook and return to review at your own pace. Download the same student worksheet PDF for pencil-and-paper practice.

Fit learning around your family’s day. There is no timer and no sign-up is needed to use the lesson. An optional account saves your lesson position and completion across devices. Workbook responses and drawings stay in this tab; save a copy of your responses before leaving.

Understand your results

Closed answers are checked in your browser. Drawings and written explanations need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

Choose Review Answers after trying the activity. The guide stays on the webpage; the worksheet download contains only the student pages.

For programme background, visit the Cambridge Lower Secondary Computing overview. PaxaKids provides independent original companion practice.

Book page references identify the related teaching topic. File-management and responsible-data preparation are original PaxaKids material; orientation or contents pages are not presented as teaching citations for those skills. The explanations, characters, programs and exercises here are original PaxaKids companion practice. Practical tasks require the appropriate editor and, where applicable, suitable equipment. A design or paper trace is not a verified hardware result. Only completed, reviewed lessons are listed.

Explore the Cambridge Lower Secondary Computing curriculum for programme background. PaxaKids is an independent learning resource.