about | help | code help+videos | done | prefs |
When bits are sent across a network, they are sometimes corrupted by interference or errors. Adding some redundant bits to the end of the transmission can help to detect these errors. The simplest error detection algorithm is known as parity checking. A bit string has even parity if it has an even number of ones, and odd parity otherwise. In an even parity scheme, the sender adds a single bit to the end of the bit string so that the nal bit string has an even number of ones. For example, if we wished to send the data 1101011, would actually send 11010111 instead so that the bit string has an even number of ones. If we wished to send 1101001 instead, we would actually send 11010010. The receiver then checks whether the received bit string has even parity; if it does not, then an error must have occurred so it requests a retransmission. Write a function evenParity(bits) that takes a string of bits as a parameter and returns True if the string bits has even parity and False otherwise. For example, evenParity('110101') should return True and evenParity('110001') should return False. evenParity('110101') → True evenParity('110001') → False evenParity('0') → True ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy