Python-Spring 2018

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

 


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003 工作时间:无休息工作日-早上8点到凌晨3点


如果您用的手机请先保存二维码到手机,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

 

发表评论