Question: Hello, I need help updating my current Python program to reflect these requirements using Python: 1 . All of the tests should run and no
Hello, I need help updating my current Python program to reflect these requirements using Python:
All of the tests should run and no output generated.
Tests will cover all of the functionality of the function and a range of the types. For instance, if you have a conditional statement, you should have a test that takes the true branch and another that takes the false branch.
Must have at least different tests per function.
def minmaxlist:
if not list:
return None, None
smallest, largest list list
for num in list:
if num smallest:
smallest num
if num largest:
largest num
return smallest, largest
def testminmax:
if minmax:
printError with minmax
if minmax:
printError with minmax
if minmaxNone None:
printError with minmax
else:
printminmax Tests Passed."
testminmax
def allpairsa b:
result
for each in a:
for other in b:
if each other and other each not in result:
result.appendeach other
return result
def testallpairs:
x
y
expectedresult
if allpairsx y expectedresult:
printError with allpairs
else:
printallpairs Test Passed."
testallpairs
def listtodictlist:
return i : listi for i in rangelenlist
def testlisttodict:
list
expectedresult : : : : : :
if listtodictlist expectedresult:
printError with listtodict
else:
printlisttodict Test Passed."
testlisttodict
def invertdictlast:
inverted
for key, value in last.items:
if value in inverted:
printfDuplicate value value found for key key Retaining only the first occurrence."
else:
invertedvalue key
return inverted
def testinvertdict:
dict : a: b: a
expectedresult a: b:
if invertdictdict expectedresult:
printError with invertdict: a: b: a
else:
printinvertdict Test Passed."
testinvertdict
def addstotargettarget Y:
seen set
for num in Y:
if target num in seen:
return True
seen.addnum
return False
def testaddstotarget:
if addstotarget:
printError with addstotarget
if not addstotarget:
printError with addstotarget
else:
printaddstotarget Test Passed."
testaddstotarget
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
