A bar chart's axis starts at a baseline above zero. Measure how much that changes the comparison readers see.
What to build
A program that compares the true and the drawn ratio of two bars.
Requirements
- Print
true ratio X(v2 ÷ v1),drawn ratio Y((v2 − baseline) ÷ (v1 − baseline)) andexaggeration Zx(Y ÷ X), each to two decimals.
Input
One line: v1, v2 and the baseline.
Output
Three lines.
Constraints
0 ≤ baseline < v1, v2 ≤ 10⁶.
Example
Input:
50 55 45
Output:
true ratio 1.10
drawn ratio 2.00
exaggeration 1.82x
Why it works
Readers judge bars by their drawn lengths, so the ratio of the drawn lengths is what they perceive; dividing it by the true ratio shows how far the axis moves that perception.
Examples
Example 1 · Input
50 55 45
Expected output
true ratio 1.10 drawn ratio 2.00 exaggeration 1.82x
Example 2 · Input
10 20 0
Expected output
true ratio 2.00 drawn ratio 2.00 exaggeration 1.00x
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
The drawn bars have lengths v1 − baseline and v2 − baseline.
Hint 2
Exaggeration is the drawn ratio divided by the true ratio.
Solution
Show one correct solution (try it yourself first)
v1, v2, base = map(float, input().split())
true = v2 / v1
drawn = (v2 - base) / (v1 - base)
print(f"true ratio {true:.2f}")
print(f"drawn ratio {drawn:.2f}")
print(f"exaggeration {drawn / true:.2f}x")