KPI Dashboard Traffic Lights

Easy ⏱ 8 min 72% acceptance ★★★★☆ 4.2
Write status(actual, target) returning 'green' when actual is at least 100% of target, 'amber' at 80-99.99%, 'red' below 80% — and handle target 0: any positive actual is green, zero actual is amber (nothing expected, nothing delivered).

Examples

Example 1
Input
status(95, 100)
Output
'amber'
Explanation

95% of target lands in the amber band.

Example 2
Input
status(5, 0)
Output
'green'
Explanation

Beat a zero target.

Constraints

  • Boundaries: >=100 green, >=80 amber.
  • Zero-target rules as stated.

Topics

Business Logicdashboards

Companies

TableauPower BI TeamDomo

Hints

Hint 1

Handle target == 0 before dividing.

Hint 2

ratio = actual / target * 100.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.