Print battery charge
Created on Jan. 23, 2018 by Antoine Angot
Write a function named battery_charge
that graphically represents
a battery’s charge. Your function doesn't need to return anything,
but just show how much a battery is charged.
This function will takes an int
between 0
and 100
as a
parameter, display a bar to represent how much the battery is "filled"
(from 0
to 10
bars), then prints the percentage.
The number of bars should be rounded, meaning that both 9% and 11% are represented by one bar.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
If the ❚
character causes you problems in your editor or terminal, feel free to
use a simple |
instead.
References
- The round builtin function.