v9.1.1
Menu

Monthly Cost of a Running Instance

easyFREEPipelines, Reliability & CostSystems & InfrastructureML Systems & Infrastructure 1

Problem Statement

Compute the monthly cost of an always-on instance given its hourly rate.

Background

A month is billed as hours_per_month = 730 hours (the cloud-standard average). Monthly cost is hourly_rate * 730 * instance_count.

Your Task

def monthly_cost(hourly_rate, instance_count):

Return the monthly cost, rounded to 2 decimals.

Input Format

  • hourly_rate (float), instance_count (int).

Output Format

  • A float rounded to 2 decimals.

Sample

print(monthly_cost(0.10, 3))

Output:

219.0

Example

Input
print(monthly_cost(0.10, 3))
Output
219.0
Reasoning
  • Inputs: hourly_rate =0.10= 0.10 is the price of one instance for one hour (dollars per hour), and instance_count =3= 3 is how many identical instances run around the clock.
  • Hours in a month: billing treats every month as the same average of 730730 hours (about 24×365/1224 \times 365 / 12), so a short February and a long March cost the same.
  • One instance: 0.10×730=73.000.10 \times 730 = 73.00 dollars (dollars per hour times hours) for the month.
  • The fleet: three identical instances cost three times as much, 73.00×3=219.0073.00 \times 3 = 219.00. Equivalently, 0.10×3=0.300.10 \times 3 = 0.30 dollars per hour for the fleet, times 730730 hours.
  • Output: 219.0, a dollar amount rounded to 2 decimal places (cents). Here the cents are zero, so it displays with a single trailing zero.
  • Notice the cost is linear in both inputs: doubling the rate or the count doubles the bill, and a rate of 00 gives 0.0 regardless of how many instances run.

Constraints

  • Use 730 hours per month.
  • Cost = hourly_rate * 730 * instance_count.
  • Round to 2 decimals.

Learn this in

More from ML Systems & Infrastructure 1

solution.py

Test results

Sign in to run your code against the test cases.