Write a python program only using loops

Assignment Help Computer Engineering
Reference no: EM132212361

Write a python program only using loops for the following question:

When data is transmitted between two computers, it is possible that the signal can encounter interference that would distort it, resulting in some of the data bits being changed.

At the very least we would like to detect when such errors occur, and in some cases it is important that we be able to correct the errors.

For instance, if we were transmitting data to a computer on a spaceship on Mars, we would not want to have to keep resending corrupted data due to the long travel delays. For this assignment you will write a program that is capable of performing a simple correction of an error in a transmitted data byte.

Assume we want to transmit 1 byte of data and be able to detect and correct any single bit that might be distorted during the transmission.

In order to do this it is necessary to transmit extra bits of information along with the byte. The values of these bits are determined in such a way that particular calculations performed at the receiving end can determine if any errors occurred. The particular algorithm you will implement adds 4 extra bits.

Assume that you start with a data byte where the 8 bits are labeled as: d1 d2 d3 d4 d5 d6 d7 d8. The full twelve bit sequence that is transmitted will look like: c1 c2 d1 c4 d2 d3 d4 c8 d5 d6 d7 d8, where the 4 extra bits are denoted by c1, c2, c4, and c8.

When these 12 bits are received, a series of calculations needs to be done as follows.

1) Look at the data bits d1, d2, d4, d5 and d7 and count how many bits are 1's. If there is an odd number of 1's, the value of c1 should be a 1. If there is an even number of 1's, the value of c1 should be a 0. If the value of c1 is not what it should be, add the value 1 to a growing sum.

2) Perform the same check with data bits d1, d3, d4, d6, d7 and c2. If there is a mismatch, add the value 2 to the sum.

3) Perform the same check with data bits d2, d3, d4, d8 and c4. If there is a mismatch, add the value 4 to the sum.

4) Perform the same check with data bits d5, d6, d7, d8 and c8. If there is a mismatch, add the value 8 to the sum.

If the final sum value is 0, then no errors occurred. If the sum value is greater than 12, then more than a single error occurred, which we cannot correct. For all other sum values, the number indicates which of the 12 bits was corrupted (they are numbered 1 - 12, going left to right), and therefore you change this value from a 0 to a 1, or a 1 to a 0 to correct the error.

Given the algorithm above, your program should do the following:

Input a string that should represent a 12 bit chunk of data that is received in a transmission. Check that the input is indeed 12 digits long. If not, print an error message. Also check whether each of the 12 digits is a 0 or 1. If there are any non-binary digits, print an error message. If the input was in error, ask the user to enter another value until they get it right.

Once valid input has been obtained, do the above calculations to determine what kind of errors might have occurred. If no error occurred, say so, and print out the correct 8 data bits in order. If a single error occurred, print out what data bit was detected as wrong, and then print out the correct 8 data bits in order. Finally, if too many errors occurred to correct, say so.

Put the entire processing of a bit sequence into a query loop, so that the user can process multiple data sequences.

You should properly comment your code, including putting your name in your source file. Any use of code from some source other than yourself should be cited in the comments.

You should not use any aspects of the Python language beyond loops. You should submit your source code as well as sample output of your program that demonstrates its operation for both good and bad data.

Reference no: EM132212361

Questions Cloud

Write a python script to generate 50 files for each : Write a python script to generate 50 files for each of the following courses: MATH222, MATH477, MATH333.
Write a queue implementation that use a circular linked list : Write a Queue implementation that uses a circular linked list, which is the same as a linked list except that no links are null.
Write a python program that will work as a point of sale : Write a python program that will Work as a point of sale system at a rodeo snack bar.
Write a random number generator function : Write a random number generator function " rand_integer" that returns a random integer between -10 and 10.
Write a python program only using loops : When data is transmitted between two computers, it is possible that the signal can encounter interference that would distort it.
Write a procedure in python that takes a positive integer n : Write a procedure in Python that takes a positive integer n as input and returns the sum of even Fibonacci numbers up to n.
Write a recursive function that accepts two arguments : Write a recursive function that accepts two arguments into the parameters x and y.
Compute the sum of the elements of an integer array : Write a recursive algorithm that computes the sum of the elements of an integer array. Prove your algorithm is correct using induction.
Test the function in the main function : Write a recursive function named "sum" with one input parameter, an integer n. The function returns the sum of numbers 1, 2, 3... n.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Prove that the distance of c is at least three

Let A be a matrix, and let C be the code consisting of all solution to Ax = 0. If A has neither a column of zeros. Prove that the distance of C is at least 3.

  Create constructors use the same exception handling

Date objects must store the date in two int instance variables: day and month, and it has to include the String instance variable, error, initialized with null.

  How many pictures could you put on the hard disk

Approximately how many pictures could you put on the hard disk, assuming you could use all the space on the disk for your pictures?

  If 32 equally spaced steps are used instead of 16 what

consider an analog signal which can range from -4v to 4v. the input signal is sampled at 20000 samples per second. the

  Discuss and develop a risk management policy

develop a risk management policy that addresses a security breaches and hot to mitigate the risks

  What advantage of assigning event handlers to event property

What are the advantages of assigning event handlers to event properties? What happens when an event handler for the on submit event returns false?

  Write a matlab program to implement a laplacian of gaussian

Write a Matlab program to implement a 7´7 Laplacian of Gaussian filter on 256x256 image using Fourier Transformasation.

  How pointers to procedures can used in ada to pass procedure

Show how pointers to procedures (or functions) can be used in Ada to pass procedures (or functions) as parameters.

  Write a program that reads and produces two files separating

Write a program that reads and produces two files separating the data for the boys and the girls, and listing them in alphabetical order.

  Search information on web page authenticity and credibility

The birth of the Internet has opened a new door for research. The World Wide Web provides endless amounts of information on just about anything you can think of. Anyone may create a Website; therefore, the question of reliability comes into play.

  Troubleshooting the software

AV software has eliminated the malware from highly infected system. After the first reboot, an error message is displayed that consists of the reference to strange DLL file that is missing.

  Develop a list of the software needed to restore operations

Establish a sample hardware assest list for this company and classify those assests as tier 1,2, or 3 assests. Develop a list of the software needed to restore.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd