Home My space log
Language EN (English)

Add a parity bit

Python Intermediate alien ages 11-13

The problem

Computers can spot mistakes by adding one extra digit. Write a function add_parity_bit(bits). The text bits is made of 0s and 1s. Add one more digit at the end (0 or 1) so that the whole text has an EVEN number of 1s. Example: "101" becomes "1010", and "111" becomes "1111".

You will practice: error detection, counting, remainder (%), joining text

Mode

Press Tab to indent. Press Esc and then Tab to move on to the next button.

Your code runs in your browser. We do not receive it or save it. Python is downloaded from cdn.jsdelivr.net the first time you run it (about 10 MB).

Test results

      What your code printed