Question
Please help me with this question in Python. # # # #=========================================================== def removeDups(L1, L2, L3): '''The inputs L1, L2, L3 are lists, return a
Please help me with this question in Python.
# # # #===========================================================
def removeDups(L1, L2, L3): '''The inputs L1, L2, L3 are lists, return a list that contains all the items in L1 and L3 but not in L2 ''' #this method requires you to use the remove() function for a list
def removeDups2(L1, L2, L3): '''The inputs L1, L2, L3 are lists, return a list that contains all the items in L1 and L3 but not in L2 ''' #this method requires you to use the append() function for a list
#do not change the code below this line def verify(L1, L2, L3, L): for item in L: if item in L2: print('{} should not be in L2, test failed'.format(item)) return False if item not in L1+L3: print('{} should be in L1+L3, test failed'.format(item)) return False
print('test passed') return True
if __name__=='__main__':
import random L1=['a','b','c', [True, False], 'd']; L2=['a','b', 1, 'd', [False, True], [1, 10] ] L3=['a','b', 1, 'D', 'E', False, True, [1, 10], [1, 10] ]
for i in range(2000): L1.append(random.gauss(0,1))
L2.extend(L1[100:600]); random.shuffle(L2); L2.extend(L1[800:2000:10]) L3.extend(L1[800:2000:50]); L3.extend(L2[-300:]+L3[:10]); ## call the two functions for tests ## for idx, i in enumerate(range(100, 1000, 100)): Lout = removeDups(L1[:i], L2[:i], L3[-i:]); Lout2 = removeDups2(L1[:i], L2[:i], L3[-i:]) v1= verify(L1[:i], L2[:i], L3[-i:], Lout) v2= verify(L1[:i], L2[:i], L3[-i:], Lout2) if v1 and v2: print("\tCongratulations, you passed test {} for Problem 1 ".format(idx)) else: print("\ttest {} failed f
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