Exercise 22.1
Map Your Own Gaps -- Role Readiness
Build the list of chapters you have genuinely worked through (not just read) and run role_readiness on it. Which role are you closest to, and what are the three highest-value chapters to close your nearest gap? Then add a fourth role of your own (say "Drilling Optimization Engineer"), define the chapters it needs, and see where you stand on it.
---
The chapter scored three petroleum-data roles against the book's chapters. Here you generalise that to any role -- including a fourth one you define -- so you can point your learning at a specific target instead of "more."
The three reference roles are embedded under a do-not-edit banner. Write one function:
def readiness(completed, required):
"""How ready a set of completed chapters is for a role that needs `required`.
Returns {'pct': percent covered, 'gaps': required chapters not yet completed}."""Exact procedure: pct = round(100 * (#required chapters you've completed) / len(required), 1); gaps is the list of required chapters (in order) that are not in completed.
At module level, define a fourth role -- Drilling Optimization Engineer, needing chapters [2, 3, 4, 5, 9, 13, 14] -- as DRILLING, and compute drilling = readiness(MY_CHAPTERS, DRILLING) for the provided MY_CHAPTERS.
Expose: readiness, DRILLING, drilling.
> Think about it: a 71% readiness with two named gaps is a to-do list; a vague > "I should learn more drilling" is not. Which single chapter closes the most of > your nearest role's gap, and is it the same chapter that would help a different > role least?
Stuck? Reveal hints one at a time — they progress from nudge to near-solution.
visibilityReveal reference solutionexpand_more
Try solving it yourself first — the hints walk you through it. The solution below is one valid approach; yours may differ and still be correct.
# ── Reference roles from the chapter (do not edit) ───────────────────────
ROLES = {
"Reservoir/Production Engineer who codes": [2, 3, 4, 5, 7, 8, 9, 10, 12, 13],
"Petroleum Data Analyst": [2, 3, 4, 5, 6, 9, 15, 20],
"Petroleum Data Scientist / ML Engineer": [2, 3, 4, 5, 16, 17, 18, 19, 21],
}
MY_CHAPTERS = [2, 3, 4, 5, 9, 13]
# ── end do-not-edit ───────────────────────────────────────────
def readiness(completed, required):
"""Percent of a role's required chapters covered, and the gaps that remain."""
done = set(completed)
have = [c for c in required if c in done]
return {"pct": round(100 * len(have) / len(required), 1),
"gaps": [c for c in required if c not in done]}
DRILLING = [2, 3, 4, 5, 9, 13, 14]
drilling = readiness(MY_CHAPTERS, DRILLING)
print("Drilling Optimization Engineer readiness:", drilling)
lockCopying code is a Full Access feature.