A phone shows a status word for its battery. Write battery_status(percent, charging):
- if the phone is charging:
"full"when the battery is at 100, otherwise"charging" - if it is not charging:
"critical"at 5% or below,"low"at 20% or below, otherwise"ok"
Examples
Input: percent = 50, charging = False
Output: "ok"
Input: percent = 3, charging = False
Output: "critical"
Input: percent = 100, charging = True
Output: "full"
Constraints
0 <= percent <= 100(integer)chargingis a boolean
Goals
- Let a boolean flag choose between two separate classification chains
- Nest an if inside another if