PIXELBANKv9.1.0
Menu

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:
  • Identify the input parameters: the hourly rate is 0.100.10 and the instance count is 33.
  • Calculate the total monthly hours by multiplying the hourly rate by the standard billing hours: 0.10×730=73.00.10 \times 730 = 73.0.
  • Determine the total cost for all instances by multiplying the single-instance monthly cost by the instance count: 73.0×3=219.073.0 \times 3 = 219.0.
  • Round the result to 2 decimal places as required by the specification: 219.0219.0 remains 219.0219.0.
  • The final output is 219.0

Constraints:

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

Test Results

0/0
Run code to see test results.