Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python 3 please Write a program that coverts a zip code to a bar code. The bar codes use large and small bars. We

In Python 3 please

Write a program that coverts a zip code to a bar code.

The bar codes use large and small bars. We will use : as a small bar and | as a large bar.

Each digit has its own bar pattern.

1 is :::||

2 is ::|:|

3 is ::||:

4 is :|::|

5 is :|:|:

6 is :||::

7 is |:::|

8 is |::|:

9 is |:|::

0 is ||:::

The barcode also includes a check digit. The final digit added to the bar code verifies the previous numbers are correct.

To Determine the checksum:

Add all the digits together

Determine what needs to be added to make the total a multiple of 10

The bar code also always starts and ends with a large bar. This is used by the scanner to align the letter.

Drexel's Zip Code is 19104

The check digit is 5. The sum of the digits is 1+9+1+0+4 = 15. To make 15 a multiple of 10, we need to add 5.

The bar code will be |:::|||:|:::::||||::::|::|:|:|:|

The majority of work in this problem is done by digit. It makes sense to store the zip code as a string, not as an integer.

Write the function checksum(zip) that takes the zip code as a string and returns the check digit as a string.

Write a function barcode(zip) that takes a zip code as a string and returns the bar code.

Develop a main program that repeatedly asks the user for zip codes and converts them to bar codes. The program will run until the user enters "exit". Remember to use if name=="main": so that ZyBooks can test your functions.

Here is an example execution.

image text in transcribed

Welcome to Bar Code Generator Enter Zip Code (exit to quit) 19104 Bar Code: Enter Zip Code (exit to quit): 19128 Bar Code Enter Zip Code (exit to quit): 07004 Bar Code: Enter Zip Code (exit to quit): exit Thanks using me

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago