> For the complete documentation index, see [llms.txt](https://kgisl.gitbook.io/lab3003/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kgisl.gitbook.io/lab3003/lab/countingbits.md).

# countingBits

countingBits

![Imgur](https://imgur.com/1lSr4mK.png)

## LED Counter <a href="#led-counter" id="led-counter"></a>

A hobbyist project involves using a Arduino board to turn on and off several LEDs, let’s assume there are 8 LEDs. The current status of the 8 LEDs that are turned on or off is captured in one single integer variable `led_status`. If a particular bit is set to value `0 (zero)`, the corresponding LED is turned off.

Write a function which accepts this integer variable `led_status` as input and returns the count of the number of LEDs that are currently switched on.

*NB: There might be more bits in the integer variable than there are LEDs. In that case, it can be assumed that those bits will also be set to 0 (zero).*

### Bonus <a href="#bonus" id="bonus"></a>

Is it possible to write a one-line code for this in Python?
