Define the is_a_valid_code() function which is passed a string code as a parameter. The function returns a boolean indicating whether the parameter string is a valid code or not. A valid code is a string made up of one letter followed by one or more digits (can also include spaces before, between or after the digits). The first three lines of code inside the function should be: "T", code_letters = min_for_each_letter = [1, 3, 4, 0, 3] #inclusive max_for_each_letter = [7, 9, 6, 7, 5] #inclusive ["S", "B", "N", "P"] where: • code_letters is the list of code letters which are valid for the first letter of the code string, • min_for_each_letter is a list which contains the minimum possible number (inclusive) for each digit following that letter, • max_for_each_letter is a list which contains the maximum possible number (inclusive) for each digit following that letter. For example, the third element of the code_letters list is the letter 'N', the corresponding third element of the min_for_each_letter list is 4 and the corresponding third element of the max_for_each_letter list is 6. This indicates that the code digits which follows the letter 'N' can be any number made up of the digits 4, 5 or 6. number part of a valid code string can also contain any number of spaces. Note: The number part of a parameter code string to be tested could contain an alphabetic character thus making the code not valid. You will find it useful to use the string method, isdigit(), which returns True if a string is a digit, False otherwise. Some examples of the function being called are shown below. For example: Test Result 1. True print("1.", is_a_valid_code('B747346')) print("2.", is_a_valid_code ( 'N 444 454')) 2. True print("3.", is_a_valid_code('T 400 4854')) print("4.", is_a_valid_code ('S 444S454')) print("5.", is_a_valid_code('P ')) print("6.", is_a_valid_code('T O ')) 3. False 4. False 5. False 6. True
Define the is_a_valid_code() function which is passed a string code as a parameter. The function returns a boolean indicating whether the parameter string is a valid code or not. A valid code is a string made up of one letter followed by one or more digits (can also include spaces before, between or after the digits). The first three lines of code inside the function should be: "T", code_letters = min_for_each_letter = [1, 3, 4, 0, 3] #inclusive max_for_each_letter = [7, 9, 6, 7, 5] #inclusive ["S", "B", "N", "P"] where: • code_letters is the list of code letters which are valid for the first letter of the code string, • min_for_each_letter is a list which contains the minimum possible number (inclusive) for each digit following that letter, • max_for_each_letter is a list which contains the maximum possible number (inclusive) for each digit following that letter. For example, the third element of the code_letters list is the letter 'N', the corresponding third element of the min_for_each_letter list is 4 and the corresponding third element of the max_for_each_letter list is 6. This indicates that the code digits which follows the letter 'N' can be any number made up of the digits 4, 5 or 6. number part of a valid code string can also contain any number of spaces. Note: The number part of a parameter code string to be tested could contain an alphabetic character thus making the code not valid. You will find it useful to use the string method, isdigit(), which returns True if a string is a digit, False otherwise. Some examples of the function being called are shown below. For example: Test Result 1. True print("1.", is_a_valid_code('B747346')) print("2.", is_a_valid_code ( 'N 444 454')) 2. True print("3.", is_a_valid_code('T 400 4854')) print("4.", is_a_valid_code ('S 444S454')) print("5.", is_a_valid_code('P ')) print("6.", is_a_valid_code('T O ')) 3. False 4. False 5. False 6. True
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
use py only
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education