We work through an if/elif ladder, then tighten the range checks using Python's chained-comparison syntax. The `a <= x < b` form replaces clumsy boolean ANDs anywhere you have ranges.
We work through an if/elif ladder, then tighten the range checks using Python's chained-comparison syntax. The `a <= x < b` form replaces clumsy boolean ANDs anywhere you have ranges.
You are given an integer timer representing the remaining time (in seconds) on a traffic signal.
The signal follows these rules:
timer == 0, the signal is "Green".timer == 30, the signal is "Orange".30 < timer <= 90, the signal is "Red".Return the current state of the signal. If none of the above conditions are met, return "Invalid".