LLM Engineering · Exercise 1 of 5Next
Intermediate
Estimate monthly cost and calls in flight
Write monthly_cost(calls_per_day, tokens_in, tokens_out, price_in, price_out, days=30) that returns the cost in dollars. Prices are dollars per million tokens, and tokens_in and tokens_out are the average tokens of one call.
Write peak_in_flight(calls_per_day, peak_factor, seconds_per_call) that returns how many calls run at the same time at the peak, rounded up to a whole number. Use average rate = calls per day / 86,400 seconds, peak rate = average x peak factor, and calls in flight = peak rate x seconds per call.
What Check tests
monthly_costfor the support-bot numbers is 15,750 dollarsdayschanges the resultpeak_in_flightis exact when the maths is wholepeak_in_flightrounds up
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.