Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Note: Use Python 3 code. Many product codes include information to classify or p

ID: 3888176 • Letter: N

Question

Note: Use Python 3 code.

Many product codes include information to classify or provide additional detail around a product. See the following product code for a sample:

HTZ10IS16-10565

The product code is comprised of 5 parts:

First 3 letters

Manufacturer (either Hertz-HTZ, Enterprise-ENT, Budget-BGT)

2 numbers after the manufacturer

Maximum allowed discount (ex 10%)

6th-7th characters

IS – in stock, OD – to order

Number before the hyphen

Year that the product was introduced

Number after the hyphen

Manufacturer product sku

Using the information above, create a program that prompts a user for a product code in the format above. The program should then print out all of the information we can determine (Manufacturer name, maximum discount, in stock or out of stock, year product was introduced, and the manufacturer sku. Use Python 3 code

First 3 letters

Manufacturer (either Hertz-HTZ, Enterprise-ENT, Budget-BGT)

2 numbers after the manufacturer

Maximum allowed discount (ex 10%)

6th-7th characters

IS – in stock, OD – to order

Number before the hyphen

Year that the product was introduced

Number after the hyphen

Manufacturer product sku

Explanation / Answer

def validateProductCode(strTestProductCode):
if iLength < 11 :
return -1;
elif "-" != strTestProductCode[9:10]:
return -1;
elif "IS" == strProductCode[5:7] or "OD" == strProductCode[5:7]:
return 1;
else:
return -1;

strProductCode=input("Enter Product code:")
iLength=len(strProductCode);
if -1 == validateProductCode(strProductCode):
print("Invalide product code:")
else:
print ("Manufacturer: ", strProductCode[0:3])
print ("Maximum Discount: ", strProductCode[3:5])
status = strProductCode[5:7]
if status == "IS":
print ("in stock")
elif status == "OD":
print ("to order")
print ("Year of product: ", strProductCode[7:9])
print ("Manufacturer product sku: ", strProductCode[10:])

Output:-

Enter Product code: HTZ10IS16-10565
Manufacturer: HTZ
Maximum Discount: 10
in stock
Year of product: 16
Manufacturer product sku: 10565

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote