Advanced
Break-even against a hosted API
Write break_even(fixed_per_month, in_tokens, out_tokens, price_in, price_out) where prices are dollars per million tokens. It returns the smallest whole number of requests per month at which the hosted cost reaches fixed_per_month (use math.ceil).
If a request costs nothing on the hosted side (the per-request price is 0 or less), return None, because there is no break-even.
What Check tests
- The lesson's numbers give 6,314,286 requests
- Doubling the prices halves the break-even
- A free hosted request has no break-even
- The result is a whole number
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.