Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write program P5.25. in PYTHON( PLS INCLUDE SCREENSHOTS OF CODE postal bar codes. For faster sorting of letters, the United States Postal Service encourages

Please write program P5.25. in PYTHON( PLS INCLUDE SCREENSHOTS OF CODE

postal bar codes. For faster sorting of letters, the United States Postal Service encourages companies that send large volumes of mail to use a bar code denoting the zip code (see Figure 10). The encoding scheme for a five-digit zip code is shown in Figure 11. There are full-height frame bars on each side. The five encoded digits are followed by a check digit, which is computed as follows: Add up all digits, and choose the check digit to

make the sum a multiple of 10. For example, the zip code 95014 has a sum of 19, so the check digit is 1 to make the sum equal to 20. Each digit of the zip code, and the check digit, is encoded according to the table below, where 0 denotes a half bar and 1 a full bar: Digit Bar 1 (weight 7) Bar 2 (weight 4) Bar 3 (weight 2) Bar 4 (weight 1) Bar 5 (weight 0).

1 0 0 0 1 1

2 0 0 1 0 1

3 0 0 1 1 0

4 0 1 0 0 1

5 0 1 0 1 0

6 0 1 1 0 1

7 1 0 0 1 0

8 1 0 1 0 0

9 1 1 0 0 0

The digit can be computed easily from the bar code using the column weights 7, 4, 2, 1, 0. For example, 01100 is 0 7 + 1 4 + 1 2 + 0 1 + 0 0 = 6. The only exception is 0, which would yield 11 according to the weight formula. Write a program that asks the user for a zip code and prints the bar code. Use: for half bars, | for full bars. For example, 95014 becomes ||:|:::|:|:||::::::||:|::|:::|||

Provide these functions: def printDigit(d) def printBarCode(zipCode)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago