Pick a storage tier from access age

Python data engineering interview problem. Difficulty: intermediate. Pattern: Filtering. About 12 minutes. Part of the Pro drill bank.

Production ticket: Reading the cloud bill starts with matching access pattern to storage class, not guessing. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

A FinOps reviewer files a ticket: objects use the wrong storage class, and the monthly bill is hard to explain. Cloud storage gets cheaper the longer data is not read, but each cheaper class costs more to read. Each object should be classified by how long ago it was last read. Return 'hot' for 0 to 29 days, 'nearline' for 30 to 89 days, 'coldline' for 90 to 364 days, and 'archive' for 365 days or more. Write storage_tier(days_since_access: int) -> str. 5 days gives 'hot'. 30 days gives 'nearline', because 30 is the first day of the next band. 120 gives 'coldline' and 400 gives 'archive'. The starter file already has the function and the print lines at the bottom. Keep them, because the grader reads what they print.

Requirements

  • Return 'hot' for 0 to 29 days.
  • Return 'nearline' for 30 to 89 days.
  • Return 'coldline' for 90 to 364 days.
  • Return 'archive' for 365 days and more.

Constraints

  • days_since_access is a whole number, 0 or more.
  • The result is one of four lowercase strings.

Examples

Input: storage_tier(5) Output: 'hot' This is the expected return value for the given call.

Topics: cloud, cost, storage.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Pick a storage tier from access age

Production ticket: Reading the cloud bill starts with matching access pattern to storage class, not guessing.

The FinOps review wants every object re-classified by how long ago it was last read. Write `storage_tier(days_since_access: int) -> str`: - 0-29 days -> "hot" - 30-89 days -> "nearline" - 90-364 days -> "coldline" - 365+ days -> "archive" Keep the prints at the bottom. The grader reads stdout.