Lawfare Group → Knowledge Institute → Lawfare Academy
Reproduce the worked examples
Copy the complete code below into a UTF-8 file named verify.py and run python verify.py with Python 3. It uses only the standard library and performs exact or rational synthetic calculations. It does not access a network or learner records. Assertions fail if the expected synthetic results change.
These checks verify the stated arithmetic and query behavior, not independent academic acceptance or production migration safety.
from fractions import Fraction as F
from math import ceil
import json
checks=[]
def ck(name,actual,expected):
assert actual==expected,(name,actual,expected)
checks.append(dict(case=name,actual=str(actual),expected=str(expected)))
ck('Customer modeled surplus',40-30,10)
ck('Returning delivery contribution',30-18-8,4)
ck('First-order contribution after acquisition',30-18-8-6,-2)
ck('Segment A modeled net',100*F(1,5)*60-400,F(800))
ck('Segment B original modeled net',300*F(1,20)*100-900,F(600))
ck('Segment B changed modeled net',300*F(7,100)*100-900,F(1200))
ck('Observed pilot purchase rate among invitees',F(8,40),F(1,5))
ck('Observed continued use among buyers, not renewal',F(3,8),F(3,8))
ck('Rebate effective tested price',50-40,10)
ck('Portfolio original incremental contribution',50*60-20*80-1000,400)
ck('Portfolio higher displacement',50*60-40*80-1000,-1200)
ck('Pricing baseline contribution',200*(100-60),8000)
ck('Pricing discount at capacity',240*(90-60),7200)
ck('Discount whole-unit contribution matching threshold',ceil(F(8000,30)),267)
ck('Discount revenue at capacity',240*90,21600)
ck('Baseline revenue',200*100,20000)
ck('Conditional lower cost only for discount',240*(90-55),8400)
fee=200*F(15,100)
ck('Platform per-sale fee',fee,F(30))
ck('Platform contribution',40*(200-fee-110),F(2400))
ck('Platform incremental original',40*(200-fee-110)-15*90,F(1050))
ck('Platform incremental higher displacement',40*(200-fee-110)-25*90,F(150))
ck('Cumulative baseline contribution',50*(400-220),9000)
ck('Original discounted campaign contribution',55*(380-220)-1000,7800)
ck('Original campaign difference',55*(380-220)-1000-9000,-1200)
ck('Unchanged price same campaign',55*(400-220)-1000,8900)
ck('Five-job acquisition-spending tie ceiling',5*(400-220),900)
ck('New transfer support only on incremental work',55*(400-220)-5*15-700,9125)
ck('New transfer incremental improvement',5*(400-220-15)-700,125)
ck('Changed support population all work',55*(400-220-15)-700,8375)
ck('Changed support population difference',55*(400-220-15)-700-9000,-625)
print(json.dumps(dict(passed=True,scope='Synthetic marketing quantities only; not verified market causality, legal compliance or learner competence',checks=checks)))