Using PYTHON 3 please help.. Below, I have written the definition for a function
ID: 3854811 • Letter: U
Question
Using PYTHON 3 please help..
Below, I have written the definition for a function. It has bugs: there are some situations where it will crash with some sort of exception. Give an example of one input that will cause an exception, and what will happen. (This would be a great unittest to add to this code....) Then, write three more unit tests (again, just give the inputs and expected results) that will each exercise a different path through the code. def quiz5_white_box(list1, list2): retva1 = [] while list1[0]Explanation / Answer
Input that cause Exception:
For all the below inputs only list index out of bounds exception is raised.
quiz5_white_box([5,4,7],[])
quiz5_white_box([],[5,4,7])
quiz5_white_box([],[])
quiz5_white_box([5,4,7],[1,2,3])
What Exception will happen:
List Index out of range.
Traceback (most recent call last):
File "C:Usersg186023workspacePythonchegg_test.py", line 11, in <module>
quiz5_white_box([5,4,7],[])
File "C:Usersg186023workspacePythonchegg_test.py", line 3, in quiz5_white_box
if list1[0]<list2[0]:
IndexError: list index out of range
UnittestInputs:
quiz5_white_box([1,3,6,7],[5,4,7]) Expected Output: [1]
quiz5_white_box([1,3,6,7],[2,3,1]) Expected output: [1,2]
print quiz5_white_box([5,4,7],[1,2,3,6]) Expected Output: [1,2,3]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.