TExcelTAD
Home › Basic Math & Pre-Algebra › Percent of a Number

Percent of a Number

"What is 15% of 80?", "12 is what percent of 48?" and "30 is 40% of what?" are the three basic percent questions. They all come from one equation, part=percent×whole\text{part} = \text{percent} \times \text{whole}. This lesson solves each kind, shows mental shortcuts, and computes discounts and tips exactly with Decimal.

One equation, three questions

part=rate×whole(rate=percent÷100)\text{part} = \text{rate} \times \text{whole} \qquad (\text{rate} = \text{percent} \div 100)

Whichever of the three numbers is missing, rearrange to find it:

Question Missing Formula Example
What is 15% of 80? part part=rate×whole\text{part} = \text{rate} \times \text{whole} 0.15×80=120.15 \times 80 = 12
12 is what % of 48? rate rate=part÷whole\text{rate} = \text{part} \div \text{whole} 12÷48=0.25=25%12 \div 48 = 0.25 = 25\%
30 is 40% of what? whole whole=part÷rate\text{whole} = \text{part} \div \text{rate} 30÷0.40=7530 \div 0.40 = 75

Tip: "of" means multiply and "is" means equals. "30 is 40% of what?" translates to 30=0.40×w30 = 0.40 \times w, so w=30÷0.40w = 30 \div 0.40.

Mental shortcuts

  • 10%: move the decimal point one place left. 10% of 340=3410\% \text{ of } 340 = 34.
  • 5%: half of 10%. 5% of 340=175\% \text{ of } 340 = 17.
  • 1%: move the point two places left. 1% of 340=3.41\% \text{ of } 340 = 3.4.
  • Build others: 15%=10%+5%=34+17=5115\% = 10\% + 5\% = 34 + 17 = 51; 20%=2×10%20\% = 2 \times 10\%; 25% = a quarter.
  • Swap trick: x% of y=y% of xx\% \text{ of } y = y\% \text{ of } x. 8% of 50 is hard; 50% of 8 is 4, and they are equal.

The three questions in code

python · try it yourself
def percent_of(pct, whole):
    return pct / 100 * whole

def what_percent(part, whole):
    return part / whole * 100

def whole_from(part, pct):
    return part / (pct / 100)

print("15% of 80      =", percent_of(15, 80))
print("12 of 48       =", what_percent(12, 48), "%")
print("30 is 40% of   ", whole_from(30, 40))
print("8% of 50       =", percent_of(8, 50), "  50% of 8 =", percent_of(50, 8))
15% of 80      = 12.0
12 of 48       = 25.0 %
30 is 40% of    75.0
8% of 50       = 4.0   50% of 8 = 4.0

Discounts and tips

A discount of r%r\% removes r%r\% of the price, so you pay (100−r)%(100 - r)\% of it. A tip or tax of r%r\% adds r%r\%, so you pay (100+r)%(100 + r)\%. Multiplying by one factor is quicker than computing the part and then adding or subtracting:

jacket 64.00, 25% off:64.00×0.75=48.00meal 46.50, 18% tip:46.50×1.18=54.87\begin{aligned} \text{jacket } 64.00,\ 25\%\ \text{off:} &\quad 64.00 \times 0.75 = 48.00 \\ \text{meal } 46.50,\ 18\%\ \text{tip:} &\quad 46.50 \times 1.18 = 54.87 \end{aligned}

For money, use Decimal and round to cents with an explicit rule:

python · try it yourself
from decimal import Decimal, ROUND_HALF_UP

CENT = Decimal("0.01")

def apply_pct(amount, pct):
    """Change an amount by pct percent (negative = discount)."""
    factor = 1 + Decimal(pct) / 100
    return (Decimal(amount) * factor).quantize(CENT, rounding=ROUND_HALF_UP)

print("jacket, 25% off:", apply_pct("64.00", "-25"))
print("meal, 18% tip:  ", apply_pct("46.50", "18"))
print("coffee 5.10, 15% tip:", apply_pct("5.10", "15"))

# the same with floats
print(5.10 * 1.15, f"{5.10 * 1.15:.2f}")
jacket, 25% off: 48.00
meal, 18% tip:   54.87
coffee 5.10, 15% tip: 5.87
5.864999999999999 5.86

The exact value is 5.10×1.15=5.8655.10 \times 1.15 = 5.865, a tie, which rounds half up to 5.87. The float product is 5.864999…, just below the tie, so formatting it with two places gives 5.86. A one-cent bug like this, repeated over millions of invoices, is exactly why money code uses Decimal.

Finding the original price

A shirt costs 36 after a 20% discount. What was the original price? It is not 36+20% of 36=43.2036 + 20\% \text{ of } 36 = 43.20. The 20% was taken off the original, so 36 is 80% of the original:

36=0.80×original→original=36÷0.80=4536 = 0.80 \times \text{original} \quad \to \quad \text{original} = 36 \div 0.80 = 45

Check: 20% of 45 is 9, and 45−9=3645 - 9 = 36. ✓

In software

  • E-commerce: discounts, coupons, VAT/sales tax, and "price before tax" from a gross price (divide by 1+rate1 + \text{rate}).
  • Resource limits: "alert when disk use passes 90%", Kubernetes CPU requests as percentages of a core, rate limiters allowing 5% of traffic to a canary.
  • Sampling: logging 1% of requests means keeping a request when random() < 0.01.

Exercises

Exercise 1: Part of a whole

Find 35% of 260 using the 10% / 5% shortcuts.

Answer

91

Solution
10% of 260=2630%=3×26=785%=26÷2=1335%=78+13=91\begin{aligned} 10\% \text{ of } 260 &= 26 \\ 30\% &= 3 \times 26 = 78 \\ 5\% &= 26 \div 2 = 13 \\ 35\% &= 78 + 13 = 91 \end{aligned}

Exercise 2: What percent?

A 1.5 GB download has finished 0.6 GB. What percent is done?

Answer

40%

Solution

rate=part÷whole=0.6÷1.5=0.4=40%\text{rate} = \text{part} \div \text{whole} = 0.6 \div 1.5 = 0.4 = 40\%.

Exercise 3: Find the whole

A 12% commission earned a salesperson 540. What were the total sales?

Answer

4500

Solution

540=0.12×sales540 = 0.12 \times \text{sales}, so sales=540÷0.12=54000÷12=4500\text{sales} = 540 \div 0.12 = 54000 \div 12 = 4500. Check: 12% of 4500=54012\% \text{ of } 4500 = 540.

Exercise 4: Price before tax

A receipt shows a gross price of 59.50 including 19% VAT. Write Python with Decimal that finds the net price and the VAT amount, rounded to cents.

Answer

Net 50.00, VAT 9.50.

Solution

Gross=net×1.19\text{Gross} = \text{net} \times 1.19, so net=59.50÷1.19=50\text{net} = 59.50 \div 1.19 = 50. VAT=59.50−50.00=9.50\text{VAT} = 59.50 - 50.00 = 9.50.

python · try it yourself
from decimal import Decimal, ROUND_HALF_UP
gross = Decimal("59.50")
net = (gross / Decimal("1.19")).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
print("net:", net, " VAT:", gross - net)
net: 50.00  VAT: 9.50

Test yourself

What is 30% of 70?

  1. 21
  2. 2.1
  3. 210
  4. 23.3

18 is what percent of 72?

  1. 18%
  2. 40%
  3. 25%
  4. 4%

After a 25% discount a game costs 45. What was the original price?

  1. 56.25
  2. 60
  3. 33.75
  4. 70