The tax already in the price
- O(1) · Trivial
- Free
- Python
- JavaScript
- operations
- decimals
Problem
The price on the shelf already has the tax inside it. Take price, the one on the shelf, and pct, the tax percentage, and return how much of that price is tax, rounded to two decimals.
Careful: the tax was added to the price before tax, not to the one on the shelf: 116 with 16% tax carries 16.00, not 18.56. If pct is 0, give 0.
Examples
116, 16 → 16
100, 16 → 13.79
250, 25 → 50
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def tax(price, pct):
passJavaScript
function tax(price, pct) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.