Index each series to 100 at its first value, so that series of different sizes can be compared on one chart.
What to build
A program that indexes several series to 100.
Requirements
- For each series print
NAME: v1 v2 ..., with every value indexed to 100 at the first and printed to one decimal.
Input
Line 1: n. Then n lines NAME v1 v2 ....
Output
n lines.
Constraints
1 ≤ n ≤ 20; 1 to 100 values per series; the first value of each series is over 0.
Example
Input:
2
A 50 55 60
B 200 150
Output:
A: 100.0 110.0 120.0
B: 100.0 75.0
Why it works
Dividing by the first value removes each series' size, so every line starts at 100 and differences between lines show differences in growth.
Examples
Example 1 · Input
2 A 50 55 60 B 200 150
Expected output
A: 100.0 110.0 120.0 B: 100.0 75.0
Example 2 · Input
1 C 3 4 5
Expected output
C: 100.0 133.3 166.7
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
Divide every value by the series' first value and multiply by 100.
Solution
Show one correct solution (try it yourself first)
n = int(input())
for _ in range(n):
name, *values = input().split()
values = [float(v) for v in values]
print(f"{name}:", " ".join(f"{v / values[0] * 100:.1f}" for v in values))