Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Suppose that an automated manufacturing tracker records production QC test results in batches in a results string

Suppose that an automated manufacturing tracker records production QC test results in batches in a results string

Computer Science

Suppose that an automated manufacturing tracker records production QC test results in batches in a results string.  For example, 

    Q2p1d1 

would indicate that a single batch of two QC tests was performed with the results of one pass and one defect.  Note that the character Q is used to start a batch of QC test results. The character p is to identify the number of tests that passed the QC test, and the character d indicates the number of defects.  More than one batch of QC test results can be reported in a single results string.  For example,

    Q2d1p1Q5p3d2 

would indicate two batches of QC test results, one with two test results and one with five test results, with a combined total of four passes and three defects.  

Precisely, to be a valid QC test results string, 

  • a batch of results must begin with the character Q (case sensitive)
  • a batch of results must report both pass and defect test results with p and d in either order
  • no leading zeros are allowed in any numeric value being reported
  • the total number of QC tests in a batch must equal the number of pass and defect test results.
  • the total number of QC tests in a batch must be greater than zero (0).  a single result string may include multiple batches of results

 

All of the following are examples of valid result strings:

 

    • Q1p0d1Q1d0p1               (two batches of results, two total tests, one pass, one defect)
    • Q5d2p3                            (one batch of results, five total tests, two defects, three passes)

All of the following are examples of invalid result strings:

    • q1p0d1                              (batch must be reported with Q)           Q1pd1                               (a number for pass is required)
    • Q1p1d                               (a number for defect is required)
    • Q1p0d1   asdfR               (extra characters not allowed)
    • Q5p00003d0002          (leading zeros not allowed)
    • Q5p0d0                          (pass and defect results must equal the total number of tests)
    • Q0p0d0                         (batch cannot be zero)

Your task

For this project, you will implement the following function, using the exact function name, parameter type, and return type shown in this specification. (The parameter and variable names may be different if you wish. Again the function name must be isValidString).

def isString(s):     

return isNotString

s is the QC test results string (see above examples of valid and invalid test result strings.)

isNotString is a boolean variable that stores either a True or False value.

This function returns true if its parameter s is a well-formed test result string described above, or false otherwise.

You should include an adequate level of comments in your code to help the code reviewer understand your code.

Save your Python program as QCString.py. Your QCString.py should include the isString() function and other supporting functions that you developed and called from the isString() function. Please remove all output statements (print()) from your functions if you used any output statements like print() to help you to test and debug.

IMPORTANT: You can only use Python built-in functions to write this program. You are not allowed to use any imported modules, packages, or libraries such as pandas, NumPy, math, etc.  the goal of this assignment is to practice:

  • Program design
  • Userdefined functions with a return value
  • Global variables
  • Boolean variables
  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Ifelif-else control statements including nested ifs.
  • While loops
  • Data type casting
  • String index, builtin string len() and isdigit() functions

You should be able to complete the assignment with the above-mentioned built-in Python features.

Make sure that you test your function with both valid and invalid test result strings. We will be testing your function with 30 test cases (QC test result strings). 

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE