Turn the five kinds of question into chart recommendations.
What to build
A program that recommends a chart for each goal.
Requirements
- Goals and charts:
compare→bar chart,trend→line chart,distribution→histogram,relationship→scatter plot,composition→stacked bar chart. - Print
GOAL: CHARTfor each goal, orGOAL: no rule for this goalfor any other word.
Input
Line 1: n. Then n goals, one per line.
Output
n lines.
Constraints
1 ≤ n ≤ 50.
Example
Input:
3
trend
compare
relationship
Output:
trend: line chart
compare: bar chart
relationship: scatter plot
Why it works
A fixed table of rules gives the same, defensible answer every time, which is what a team's chart chooser is for.
Examples
Example 1 · Input
3 trend compare relationship
Expected output
trend: line chart compare: bar chart relationship: scatter plot
Example 2 · Input
2 composition ranking
Expected output
composition: stacked bar chart ranking: no rule for this goal
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
A dictionary from goal to chart makes the lookup one line.
Hint 2
Use dict.get with a default, or check membership first.
Solution
Show one correct solution (try it yourself first)
CHARTS = {
"compare": "bar chart",
"trend": "line chart",
"distribution": "histogram",
"relationship": "scatter plot",
"composition": "stacked bar chart",
}
n = int(input())
for _ in range(n):
goal = input()
print(f"{goal}: {CHARTS.get(goal, 'no rule for this goal')}")