Price with tax

Work out a price including tax.

What to build

A program that converts two inputs, calculates and shows neat money values.

Requirements

  • Read the price and the tax percentage.
  • Print Tax: T and then Total: P, each with two decimal places.

Input

Two lines: the price, then the percentage. Either may have decimals.

Output

Two lines, as in the example.

Constraints

The price is from 0 to 1000000, and the percentage is from 0 to 100.

Example

Input:

100
15

Output:

Tax: 15.00
Total: 115.00

Why it works

float accepts both 100 and 99.5. Calculating with the full value and rounding only when showing it keeps the sum accurate.

Examples

Example 1 · Input
100
15
Expected output
Tax: 15.00
Total: 115.00
Example 2 · Input
99.5
10
Expected output
Tax: 9.95
Total: 109.45

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Both inputs can have decimals, so use float.

Hint 2

The tax is price * percent / 100.

Hint 3

f"{value:.2f}" shows two decimal places.

Solution

Show one correct solution (try it yourself first)
price = float(input())
percent = float(input())
tax = price * percent / 100
print(f"Tax: {tax:.2f}")
print(f"Total: {price + tax:.2f}")

Lesson: Input and type conversion →