Apply Per-Item Tax Rates

Medium ⏱ 12 min 63% acceptance ★★★★☆ 4.4
Given parallel lists prices and tax_rates (as decimals like 0.18), write gross_prices(prices, tax_rates) returning each price with its own tax applied, rounded to 2 decimals, via zip inside a comprehension.

Examples

Example 1
Input
gross_prices([100, 200], [0.18, 0.05])
Output
[118.0, 210.0]
Explanation

100×1.18 and 200×1.05.

Constraints

  • Use zip in a comprehension.
  • Round each result to 2 decimal places.

Topics

List Comprehensionszip

Companies

PayPalDeloitteJPMorgan Chase

Hints

Hint 1

zip pairs the two lists element-wise.

Hint 2

round(p * (1 + r), 2).

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.