DVPPython Studio
Module 2: Make editorial decisions / Build 3 of 4

Score prompt adherence

Implement and explain a weighted heuristic using typed observations, not truthiness or invented certainty.

Runs on your computer · 45–65 minutes · no paid services

Download practice filesFiles, commands & notes

Without JavaScript, use the step links and keep your files on your computer.

One useful idea

The five observations are supplied by a person or fixture; this function does not examine a prompt or video. A weighted rubric combines those observations under a declared policy. Its output must say heuristic, not objective quality.

Subject/action/setting/camera/style weigh 30/25/20/15/10 and total 100. Validate the dictionary, exact keys and actual bool values before scoring. The string "false" is truthy, while 0/1 are numbers; none is an accepted observation type here.

Iterate the declared weights, not the caller’s key order. Sum passed weights and return failed names in subject/action/setting/camera/style order. Do not modify the input or reuse an old failed list. All 32 boolean combinations can be checked because the input space is deliberately small.

Refresh first: Transparent rules, Booleans, Counts and denominators.

Trace a finished example

from qc_tools import score_adherence

observed = {
    "subject": True, "action": False, "setting": True,
    "camera": True, "style": True,
}
print(score_adherence(observed))

The result is {"kind":"heuristic","score":75,"failed":["action"]}. Missing action removes 25 points. That number depends on the declared weights and supplied judgments; it is not evidence of independent media analysis.

The finished implementation is in qc_tools.py. Reading it is guided practice, not independent evidence.

Predict the weighting

Missing style alone versus missing action alone?

Compare your answer · self-reviewed

90 versus 75. Different declared weights mean these are not equal-count percentages.

Find the truthiness bug

Why refuse the text "false"?

Compare your answer · self-reviewed

It is a nonempty string, so a truthiness test would count it as passed. Require actual bool observations.

Explain the limitation

Does a score of 100 prove a video meets every creative goal?

Compare your answer · self-reviewed

No. It only combines five supplied judgments under this rubric. Unobserved criteria and human disagreement remain outside the score.

Try the idea in this browser

Runs in this browser · optional preparation · local project checks remain separate

Try a small function before opening your local files. Python downloads when you choose Run; if it cannot load, your code stays here and the local kit still works. The worker executes on your device, not on a DVP server. Only run code you trust: this is not a hostile-code security sandbox.

JavaScript loads the practice controls. Python starts only after Run.

Read the browser task briefs without running Python

Trace the declared policy

Read the complete function, predict a changed case, then Run. Write score_adherence(observed) using supplied WEIGHTS: subject 30, action 25, setting 20, camera 15, style 10. Require a dictionary with exactly these five keys and actual bool values; missing/extra keys raise ValueError, wrong container/value types raise TypeError. Return {kind: heuristic, score: native integer sum of true weights, failed: false keys in declared order}. Do not mutate input; use a fresh failed list each call. These are supplied observations, not automated video analysis. Return the specified data for new inputs; wrong types raise TypeError and refused values raise ValueError. These classroom rules do not analyze media or establish objective quality.

Implement the policy independently

Write score_adherence(observed) using supplied WEIGHTS: subject 30, action 25, setting 20, camera 15, style 10. Require a dictionary with exactly these five keys and actual bool values; missing/extra keys raise ValueError, wrong container/value types raise TypeError. Return {kind: heuristic, score: native integer sum of true weights, failed: false keys in declared order}. Do not mutate input; use a fresh failed list each call. These are supplied observations, not automated video analysis. Return the specified data for new inputs; wrong types raise TypeError and refused values raise ValueError. These classroom rules do not analyze media or establish objective quality.

Change it, then build your own

One controlled change

Compare all true, all false and missing action. Then reverse the input dictionary order; the failed-name order must remain the declared rubric order.

Your independent task

Write score_adherence(observed) using supplied WEIGHTS: subject 30, action 25, setting 20, camera 15, style 10. Require a dictionary with exactly these five keys and actual bool values; missing/extra keys raise ValueError, wrong container/value types raise TypeError. Return {kind: heuristic, score: native integer sum of true weights, failed: false keys in declared order}. Do not mutate input; use a fresh failed list each call. These are supplied observations, not automated video analysis. Implement it in practice.py. You may use WEIGHTS; do not import the finished scorer.

What success looks like

Four adherence test methods pass, including all 32 combinations, missing/extra keys, nonboolean values, input preservation and fresh outputs.

Hint 1 · a question

List the five weights and predict missing action versus missing style.

Hint 2 · a concept cue

Validate the container, exact keys and actual bool values before adding true weights.

Hint 3 · a localized example

Iterate WEIGHTS order, not incoming dictionary order. Sum true weights and collect false names in a new list; label the result heuristic.

Need the complete worked solution?

Open qc_tools.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.

Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.

Repair a failed check

If a true-looking string passes, validate value types before summing. If failed keys change order, iterate WEIGHTS. If one call changes the next, create a new list inside each call.

NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.

Show it works on new inputs

Write three scored examples with the supplied observations, weights and failed names. Explain how a changed rubric would change the score, and why that does not change the underlying observed evidence.

Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.

Keep the idea

A transparent heuristic is useful precisely because its inputs, weights and limitations are visible.