Home My space log
Language EN (English)

Spot a parity error in a row

Python Beginner robot ages 11-13 From CS Unplugged

The problem

In the parity magic trick, every row should have an EVEN number of black cards. Write a function has_parity_error(row). row is made of B (black) and W (white). Give back True if the row has an error (an odd number of B), and False if it is fine.

You will practice: counting, remainder (%), true and false

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

      
          

      CC BY-SA 4.0

      Adapted from a CS Unplugged programming challenge by the University of Canterbury Computer Science Education Research Group, licensed CC BY-SA 4.0.

      Original challenge · License: CC BY-SA 4.0

      Changes: Rewritten in our own words as a function with tests, hints and steps, in Python and JavaScript, by Open Cosmos. This version is also CC BY-SA 4.0.