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

  Write a program to input a prufer sequence and output

Write a program to input a Prufer sequence and output the unique tree for that sequence.

  Find out the min-term of the circuit

find out the min-term of the circuit - Find the min-term expansions for X, Y, and Z (i.e. the Standard SOP expression for each). Put your final answer in short-hand notation (e.g. Sum of minterms(1, 4, 6)).

  Create a map that contains an individuals jnumber

Create a map that contains an individuals Jnumber and their names. use a switch that will allow a user to enter the info into the map.

  How to modify the perimetercalc class

how to modify the PerimeterCalc class so that a caller who has a square plot will be able to provide only one argument value for length and width (rather than two that are just the same) in the method invokation.

  What researchers were surprised to discover with dll file

Write a three to four page paper in which you: Identify what researchers were surprised to discover with Stuxnet's malicious DLL file.

  Write a method that computes the average of the neighbors

Write a method that computes the average of the neighbors of a two-dimensional array element in the eight directions public static double neighborAverage(int[][

  Define ofb and list its advantages and disadvantages

Define CBC and list its advantages and disadvantages. Define CFB and list its advantages and disadvantage. Define OFB and list its advantages and disadvantages.

  After delivering the concepts behind the application system

after delivering the concepts behind the application system and user interface requirement process the government

  Determine the centroids of the quantization regions

[Determining the Centroids] Determine the centroids of the quantization regions for a zero-mean, unit-variance Gaussian distribution.

  Create a program plan and then convert

Create a program plan and then convert it into C++ statements. Practice debugging, declaring variables, file I/O, functions, arrays, sorting and searching array

  Write a new method in the rectangle class to test

Write a new method in the Rectangle class to test if a Point falls within the rectangle.

  New network equipment based on the above description

A fast and reliable PLC communications network is important to ensure that production remains uninterrupted. If equipment failure occurs, time is spent on troubleshooting and repair.

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