dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.8 KiB
1.8 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68b06e589bf2273243814777 | Challenge 39: Fill The Tank | 29 | challenge-39 |
--description--
Given the size of a fuel tank, the current fuel level, and the price per gallon, return the cost to fill the tank all the way.
tankSizeis the total capacity of the tank in gallons.fuelLevelis the current amount of fuel in the tank in gallons.pricePerGallonis the cost of one gallon of fuel.- The returned value should be rounded to two decimal places in the format:
"$d.dd".
--hints--
cost_to_fill(20, 0, 4.00) should return "$80.00".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(cost_to_fill(20, 0, 4.00), "$80.00")`)
}})
cost_to_fill(15, 10, 3.50) should return "$17.50".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(cost_to_fill(15, 10, 3.50), "$17.50")`)
}})
cost_to_fill(18, 9, 3.25) should return "$29.25".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(cost_to_fill(18, 9, 3.25), "$29.25")`)
}})
cost_to_fill(12, 12, 4.99) should return "$0.00".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(cost_to_fill(12, 12, 4.99), "$0.00")`)
}})
cost_to_fill(15, 9.5, 3.98) should return "$21.89".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(cost_to_fill(15, 9.5, 3.98), "$21.89")`)
}})
--seed--
--seed-contents--
def cost_to_fill(tank_size, fuel_level, price_per_gallon):
return tank_size
--solutions--
def cost_to_fill(tank_size, fuel_level, price_per_gallon):
gallons_needed = tank_size - fuel_level
cost = gallons_needed * price_per_gallon
return f"${cost:.2f}"