Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pyhton 3.0 HELP!! a5q2_functions.py: def merge(listA, listB): ''' Given 2 lists whose elements are in increasing order, merge them into one list of elements in
Pyhton 3.0 HELP!!
a5q2_functions.py:
def merge(listA, listB): ''' Given 2 lists whose elements are in increasing order, merge them into one list of elements in increasing order :param listA: a list in increasing order :param listB: a list in increasing order :return: a list with all elements in increasing order ''' result = [] indexA = 0 indexB = 0 while indexA Purpose: More practice writing test-cases and implementing test-drivers. Degree of Difficulty: Moderate In the document a5q2 functions.py you'll find the function merge Given 2 lists whose elements are in increasing order, merge them into one list of elements in increasing order The code is below. The idea is to step through both lists one element at a time. Compare two elements, one from each list, and put the smaller into the merged list. If you reach the end of either list, add the rest of the other list to the end of the merged result def nerge (list A, list B) Given 2 lists vhoae elements are in increasing order merge them into one list of elements in increasing order param list a list in increasing order param list a list in increasing order a list with all elements in increasing order return result inder inderB vhile in dexA len (list A) 1 and inderB len (list B) step through the lists elenent at a time put the smaller element in the result if list index AJ BlinderBJ result. append (list Cinder AJ) inder inder 1 else results .append ClistA LindexA]) inderB inder 1 add the remaining elements if index len (listA) reault extend (list Cinder result return This function contains errors. Your task will be to find the errors using testing. You'll hand in an explanation of what the errors are, and how you fixed them, but you will not hand in the corrected code. 1. Write white-box and black-box tests for the function merge You should do this without Python, either on paper or in a simple document. Don't worry about running your tests until you have thought about which tests you want. Make sure you have at least 3 black-box tests, and 3 white-box tests, as a minimum. More tests may be useful. 2. Implement your test cases in a document named a5q2 testing.py. This can be done using the techniques given in the textbook (Chapter 15), or as demonstrated in the Lab 8. 3. Run your tests, and copy/paste the console output to a document named a5q2 output.txt. The console output you hand in should come from the program before you try to fix it A. Try to deduce the problems with the mergel) function from the output of your testing. Then fixtheerrors in the function, so that your test driver does not indicate any faults. 5. In the document a5q2 output.txt, describe the error(s) you found, and how you fixed it (them). You do not need to write a lot; a sentence or two for each error is all we want. Write your explanation as if you are explaining the error to a colleague of yours who wrote the function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started