in reply to Mathematics skills

Your logic is fine. You may want to also print a newline or some spaces, just for readibility.

The pack and unpack functions are very handy for that, and are probably the best choice. Also oct can produce a number from a binary string representation, and vec can be used to set and unset bits.

After Compline,
Zaxo