Code: TU23 Points: 25
Starter Code
In this challenge you will learn how to do a simple parity check. Before you run the code, try and guess what you think it will do?
Starter Code
In this challenge you will learn how to do a simple parity check. Before you run the code, try and guess what you think it will do?
The code explained
There are some parts to this code you might now have seen before.
2 my_byte = str(input("Input your byte:"))
Normally in Python we don't need to specify that it is a string, but Python is likely to see these as integers and unhelpfully convert for us.
for i in my_byte:
Python enables you to loop directly through any string or list.
count%2
Modulo calculates the remainder rather than doing division.
There are some parts to this code you might now have seen before.
2 my_byte = str(input("Input your byte:"))
Normally in Python we don't need to specify that it is a string, but Python is likely to see these as integers and unhelpfully convert for us.
for i in my_byte:
Python enables you to loop directly through any string or list.
count%2
Modulo calculates the remainder rather than doing division.
Exercise 1: Add to code above and make it so that it adds an ODD parity check.
Exercise 2: Check it with this test data:
0110111 Parity Bit 0
0001111 Parity Bit 1
1111111 Parity Bit 0
If it works then you can submit this challenge
Exercise 2: Check it with this test data:
0110111 Parity Bit 0
0001111 Parity Bit 1
1111111 Parity Bit 0
If it works then you can submit this challenge