Perl代写 | UNIX Systems Programming Assignment

1) Write a Python program that prints the frequencies of words in the text file. Your output should be similar to the one shown below (same alignments and table-like format). Submit your (1) program and (2) a snapshot (picture of at least first 7 words in your table) of your results.

word frequencies

2) Write a Python program that reads the text from the file and writes its translation in the file hw8PirateOutput.txt. Use the translation described by Pb.4.3 from pg. 153. Note: in your output file you are allowed to have all words in lower case. Submit the (1) python code and (2) the file hw8PirateOutput.txt.

3) Write a Python program that verifies the check digit of Universal Product Codes (UPC).

The Universal Product Codes on almost all purchase items utilizes a bar code to allow for the scanning of items. Below the bar code is the sequence of digits that the bar code encodes, as illustrated below.

Bar code image

The last digit of the product code (2) is a check digit computed as follows.

  1. Add up all digits in the odd numbered positions excluding the last check digit, and multiply the result by 3.

0+6+0+2+1+5=14
14*3=42

  1. Add up all digits in the even numbered positions excluding the last check digit.

3+0+0+9+4=16

  1. Take the sum of the two previous results modulo 10.

(42+16) modulo 10 = 8

  1.  Subtract the result from 10 to get the checksum digit.

10-8=2

The file contains many UPCs. Your program must read them from the file, and for each UPC it must display True if the check digit verifies as described above; otherise it displays False. Take a snapshot of your output similar to the one below, and upload it with your homework. Submit ypur (1) Python code and (2) a snapshot (picture) of your results.

UPC