Python: Postal Code Programming Exercise (Ep. 2)
October 11, 2020
In this video, you’re going to create a Python program that asks the user for a 5-digit zip code and prints the bar code. 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.
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, the encoding scheme for a five-digit zip code 95014 becomes:
||:|:::|:|:||::::::||:|::|:::|||
Provide and implement these functions:
def main() # Main entry to start the program
def getDigit() # Reads and return the 5-digit zip code
def printDigit(d) # Prints the bar code for a digit
def printBarCode(zipCode) # Prints the encoded bar code