Skip to course content
Free course

Python Foundations / Module 2 / Applied Checkpoint: Clean a Course Record

Module 2 lesson

Applied Checkpoint: Clean a Course Record

Unit ID: M02-U08 Estimated active time: 35-50 minutes

Your task

Clean and summarise this fictional course record:

raw_course_name = "  PYTHON foundations FOR ai  "
raw_course_code = " py-ai-02 "
raw_planned_hours = " 32 "
raw_status = " PLANNED "
instructor_name = None

Do not replace the raw values. Create new, clearly named clean values so the original evidence remains visible.

Required transformations

  1. Remove outside whitespace from every text input.
  2. Create a display course name in title case, then correct Ai to AI.
  3. Create an uppercase course code.
  4. Convert planned hours to an integer.
  5. Create a lowercase status.
  6. Create a boolean named is_available by comparing the clean status with "available".
  7. Confirm explicitly whether instructor_name is None.
  8. Extract the first two characters and final two characters from the clean course code.

Required summary

Use f-strings to print labelled lines containing:

  • course name;
  • course code;
  • planned hours;
  • status;
  • availability boolean;
  • whether an instructor name is missing;
  • the two-character code prefix; and
  • the two-character code suffix.

Predict before running

Write down:

  • the clean course code;
  • the integer planned hours;
  • whether is_available will be True or False; and
  • the code prefix and suffix.

Then run the program and compare.

Required inspection

Print the types of:

  • the raw planned-hours value;
  • the clean integer planned-hours value;
  • the availability value; and
  • the instructor value.

Explain why each type is suitable or what future validation may still be needed.

Clean-rerun test

Restart the kernel and run all cells from top to bottom. Confirm that no clean value depends on hidden state and that the raw values remain unchanged.

Self-review rubric

CriterionNot yetMeets
Raw evidenceRaw values are overwrittenRaw and cleaned values remain separate
Text cleaningWhitespace or required case remains incorrectName, code, and status follow the stated rules
ConversionPlanned hours remains text or is converted without explanationPlanned hours is an integer created from suitable cleaned text
Boolean and absenceAvailability or missing instructor is guessedBoth are created with explicit comparisons
SlicingPrefix or suffix is incorrectBoth two-character slices are correct
OutputResults are unlabelled or joined unsafelyF-strings provide clear labelled output
TypesRequired type inspection is absentAll four required types are inspected and explained
ReproducibilityClean rerun fails or changes raw evidenceRestart-and-run-all succeeds with raw values preserved

Complete the checkpoint only when every criterion meets the standard.