Skip to contentSkip to navigation

Module 11

Standard Library Power Tools

Solve practical problems using regex patterns, dates and times, randomness, and statistics.

// Lessons

6

// Quiz questions

90

// Reading time

180 min

// Exam length

15 Q

// Coding exercises

10

  1. 1Regular Expression FundamentalsMatch character classes, set boundary anchors, and scan raw string patterns with re.search and re.match. 30 min 15 questions
  2. 2Advanced Regex & Group SubstitutionExtract structured data with named capture groups, replace substrings with re.sub, and use lookarounds. 30 min 15 questions
  3. 3Dates, Times & TimedeltasCalculate calendar intervals, extract timestamp components, and handle UTC timezone offsets. 30 min 15 questions
  4. 4Date Parsing & Formatting (strptime/strftime)Convert raw timestamp strings into datetime objects and format dates for localized user display. 30 min 15 questions
  5. 5Random Numbers & Cryptographic SecretsGenerate reproducible test distributions with random and produce secure tokens with the secrets module. 30 min 15 questions
  6. 6Math & Statistical ComputationsPerform precision math operations, analyze datasets with mean and median, and calculate variance. 30 min 15 questions

Coding practice: write it yourself

Real Python, real checks: write your answer, press Run checks, and keep going until it passes. (4 exercises)

All module exercises

Coding practice needs an account. Sign in or create a free ID to run these exercises.

Lab 1: Extract digits

Sign-in required

Use re.findall(r"\d+", "Item 42 costs 150 taka"). Print the extracted list of digit strings: ['42', '150'].

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

Lab 2: Days difference

Sign-in required

Calculate the days between date(2026, 1, 1) and date(2026, 1, 10). Print: Days: 9.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

Lab 3: Sample without replacement

Sign-in required

Set random.seed(5). Sample 2 items from ['cat', 'dog', 'bird', 'fish'] using random.sample(). Print: Sampled 2 items: True.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

Lab 4: Statistics mean

Sign-in required

Compute the arithmetic mean of [10, 20, 30, 40] using statistics.mean(). Print: Average: 25.0.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

References & Further Reading

Related entries from PyLabs's own reference library.

  • round() (Round a number to a chosen number of digits.)
  • replace() (Replace matching text with new text.)