Index Ai Academy
Phase 0 · ToolsNumbers for code

Fractions, ratios and rates

About 20 minLooking ahead: some prerequisites aren't done yet

Why this matters

Most numbers in AI work are fractions in disguise. A click rate is clicks over views. A model's accuracy is right answers over all answers. When a model is "0.73 sure", that's a share of one whole. Mix up a count with a rate, or a percent with a percentage point, and you'll back the wrong campaign or misread a result. This lesson makes fractions, rates and ratios second nature, with Python doing the arithmetic.

  • Turn a fraction into a decimal and a percentage, and back again
  • Compare groups of different sizes with rates instead of counts
  • Tell a percent change from a change in percentage points
  • Scale amounts up and down with a ratio, and compare unit prices
Quick check
Before any explaining, a guess. Shop A sold to 30 of its 200 visitors; shop B sold to 45 of its 450. What does this print?
a = 30 / 200
b = 45 / 450
print(a, b)

A fraction is a division

A fraction says how much of a whole you have. 3/4 of a pizza means it was cut into 4 equal slices and you have 3. The line in the middle means divide: 3 ÷ 4 = 0.75. The same amount can be written three ways:

fractiondecimalpercent
3/40.7575%
1/20.550%
1/80.12512.5%

Fractions that look different can be the same share: 3/4, 6/8 and 75/100 are all 0.75. Dividing turns each one into a single number, which is the easiest way to compare them.

Percent means "out of a hundred", so to turn a decimal into a percent, multiply by 100. To go back, divide by 100:

part = 3
whole = 8
share = part / whole
print(share)              # as a decimal
print(share * 100, "%")   # as a percent
print(25 / 100)           # 25% back as a decimal