Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A company uses codes to represent its products, for example ABC 2 4 7 5 A 5 R - 1 4 . Valid codes must

A company uses codes to represent its products, for example ABC2475A5R-14. Valid codes must have:
At least 10 characters (some codes have more than 10 characters)
Positions 4 through 7 must be digits (and represents the country in which the product will be sold)
The character in the 10 th position must be a capital letter and represents the security level of the product.
Write a Python program that will read 10 product codes from a text file (Codes.txt - attached below). Determine if each conforms to the rules listed above:
If it does conform, print a heading: Valid Code(s) are: and list the codes that are valid. If it does not conform, print a heading: Invalid Code(s) are: and list the
codes that area invalid. Be sure to test all possible combinations.
Further, if the code is valid, due to new government security laws, products with a security level of R(restricted) are no longer to be sold in countries with a
country code of 2000 or higher. Output a heading: Invalid Restricted Code(s) are: and list the codes that are invalid in case you encounter any products that
violate these new laws. XYZ2755R-14
RST1234A6A-12
UVW24a6R7R-13
PQR3999F85-11
STI1281J9A-04
FOR2561T4R-54
BID2075U3R-55
AGA1475P1B01
JBT2175E5X-04
KAM1145X2R-05
image text in transcribed

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions