ASCII Encodings and 8 Bit Representations Dictionaries Lab Report 6 Lab 6: Dictionaries Learning outcomes Gain experience with dictionaries. Prelimin
ASCII Encodings and 8 Bit Representations Dictionaries Lab Report 6 Lab 6: Dictionaries
Learning outcomes
Gain experience with dictionaries.
Preliminaries
ASCII (American Standard Code for Information Interchange) is an older code used by computers to represent characters (such as the character “X”) with 8 binary digits (or bits). Here is an ASCII table. Today, Unicode UTF-16, a 16 bit code is more commonly used.
Download lab6.py, rename it according to the instructions above, and make sure you understand it.
Download input file ascii-codes.csv to the same directory where you downloaded lab6.py. Each line in ascii-codes.csv contains 8 bits (0s and 1s), followed by a comma, followed by the character that the 8 bits represents. In general, the character will be of length 1 such as the character X. However, there are two exceptions: “ “ is represented by space and “,” is represented by comma.
Assignment
Take the program above and modify it by adding the create_dictionary function. The parameter file_name is the name of a csv file that contains an unknown number of lines that reflect ASCII encodings. The format of this file is described in the bullet above. The function should return a dictionary where the keys are characters and the values are the 8 bit representations. Note: use ” ” and “,” as keys instead of space and comma.
Take the program above and modify it by adding the translate function. The parameter sentence consists of an unknown number of characters. The parameter dictionary is the dictionary that was created by the create_dictionary function. The parameter file_nameis the name of the output file where all output should be sent. In the output file, each character in sentence should appear on its own line, followed by a space, followed by its 8 bit representation. If a character does not appear in the dictionary, the word UNKNOWNshould appear instead of an 8 bit representation.
When the program is run, it should produce the following three output files: output-1.txt, output-2.txt and output-3.txt .
Grading – 10 points
2 points – The create_dictionary function returns a dictionary that contains the correct binary code for each character of length one.
1 point – The create_dictionary function returns a dictionary that contains the correct binary code for “ “ and “,”.
4 points – When your program is tested with different values for the variable sentence, characters that exist in the dictionary are translated correctly. For each different character that is translated incorrectly, one point will be deducted.
1 point – When your program is tested with different values for the variable sentence, characters that do NOT exist in the dictionary are translated correctly to UNKNOWN.
1 point – The format of any output files created match the format of the sample output files exactly.
1 point – In a comment at the top of the python file that you submit, explain why the comma character and the space character are treated differently in ascii-codes.csv.
Grading turnaround
All labs graded with scores recorded in BrightSpace no later than office hours following class day.
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
Confidentiality
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.