def cost_per_mille(spend, impressions):
 if impressions:
  return ((1000.0 * float(spend)) / impressions)
 else:
  return 0

def cost_per_mille ( spend , impressions ) : if impressions : return ( ( 1000.0 * float ( spend ) ) / impressions ) else : return 0
return the cost-per-mille given ad spend and impressions .