Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Imagine you're writing the software for an inventory system for #a store. Part of the software needs to check to see if inputted #product codes

image text in transcribed

#Imagine you're writing the software for an inventory system for #a store. Part of the software needs to check to see if inputted #product codes are valid. # #A product code is valid if all of the following conditions are #true: # # - The length of the product code is a multiple of 4. It could # be 4, 8, 12, 16, 20, etc. characters long. # - Every character in the product code is either an uppercase # character or a numeral. No lowercase letters or punctuation # marks are permitted. # - The character sequence "A1" appears somewhere in the # product code. # #Write a function called valid_product_code. valid_product_code #should have one parameter, a string. It should return True if #the string is a valid product code, and False if it is not.

False False 21 #Add your code here! 22 def valid_product_code (string): 23 % 4-0: 24 25 26 27 28 29 30 31 32 if len string) for cin list(string): if c "Al": for c in list (string) if c - c.lower): elif c(or"." or" or":") else: return False return False return True else: return False 34 35 36 37 38 39 40 41 #Below are some lines of code that will else: return False test your function. 43 Yunc tion chat ditferent tnputhe variable() to test your 43 #function with different inputs. 44# 45 #If your function works correctly, this will originally 46 #print: True, True, False, False, False 47 print (valid product code( "A12844BP 48 print(valid_product_code("BFDSAUSA98932RWEFOEWA9FEAA1DSFSF")) 49 print (valid product code("A1BBDS") 50 print (valid_product code(BDD5664S") 51 print (valid_product_code "66aBSaA1fdsv"))

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

what is objectives, goals, vision and mission for students project

Answered: 1 week ago