Question: There are two pythons files below: assignment1.py and verification1.py Complete the assignment1.py. Only modify this file. Put code in after the line ######### YOUR CODE

There are two pythons files below: assignment1.py and verification1.py Complete the assignment1.py. Only modify this file. Put code in after the line ######### YOUR CODE STARTS HERE ################

After you finish assignment1.py code, you should be able to use assignment1.py to run the verification1.py. The correct output is a long number.

 assignment1.py #### Note: In the case of dictionaries, use the keys as the determining factor for all work on the data structures #### Note: You can give preference to data structure a over b, but no use case will require that you have done this. #### This means if a is a dictionary with keys "a","b", and "c" and b is a dictionary with key of "a" #### You will not be tested as two which value for key "a" would be in the result #### Note: You will only be tested in which both data structures are the same type, no a is a list and b is a tuple. #### The result of the methods will be tested to ensure they are the same data structure as a and b def unionOfTwoDataStructures(a,b): result = None #Find the concatenation of the data structures (with no uniqueness guarantee) a and b and set the return variable 'result' to this value #Note: if you ensure that each value from a and b only occurs once, it may make other methods easier to complete #Note: While using concatenation will get you most of the way to this, it will not result in only unique values if type(a) is list and type(b) is list: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is tuple and type(b) is tuple: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is dict and type(b) is dict: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ else: print "a and b have to both be either lists, tuples, or dictionaries" return result def intersectionOfTwoDataStructures(a,b): result = None #Find the elements of both of the data structures a and b and set the return variable 'result' to this value #Note: if you ensure that each value from a and b only occurs once, it may make other methods easier to complete if type(a) is list and type(b) is list: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is tuple and type(b) is tuple: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is dict and type(b) is dict: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ else: print "a and b have to both be either lists, tuples, or dictionaries" return result def symmetricDifferenceOfTwoDataStructures(a,b): result = None #Find the elements that are not common to both data structures a and b and set the return variable 'result' to this value #Note: you may be able to use other methods together to get this done without much extra code, look up venn diagrams to see # how this could happen ######### YOUR CODE STARTS HERE ################ if type(a) is list and type(b) is list: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is tuple and type(b) is tuple: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is dict and type(b) is dict: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ else: print "a and b have to both be either lists, tuples, or dictionaries" ######### YOUR CODE ENDS HERE ################ return result def equalityOfTwoDataStructures(a,b): result = None #Determine if the two data structures passed in as variables are equivalent and place the associated # boolean value of True or False into the variable result ######### YOUR CODE STARTS HERE ################ if type(a) is list and type(b) is list: #Note: Equality of two lists means that they contain all of the same values, it does not mean # mean that both lists have them in same order or do not include duplicates ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is tuple and type(b) is tuple: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ elif type(a) is dict and type(b) is dict: ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ else: print "a and b have to both be either lists, tuples, or dictionaries" ######### YOUR CODE ENDS HERE ################ return result def test_all_methods(a,b): result = [] result.append(unionOfTwoDataStructures(a,b)) result.append(intersectionOfTwoDataStructures(a,b)) result.append(symmetricDifferenceOfTwoDataStructures(a,b)) result.append(equalityOfTwoDataStructures(a,b)) return result

_______________________________________________________________________________________________________________________________________

verification1.py

import assignment1 if 64 - 64 : i11iIiiIii def oo000 ( ) : ii = [ 1 , 2 ] oOOo = [ 2 , 3 ] O0 = module2_assignment2 . test_all_methods ( ii , oOOo ) o0O = iI11I1II1I1I ( O0 [ 0 ] , [ 1 , 2 , 3 ] ) oooo = True if not o0O : print "Your program is having issues with list union. Expected [1, 2, 3], but it output %s" % ( str ( O0 [ 0 ] ) ) oooo = False iIIii1IIi = iI11I1II1I1I ( O0 [ 1 ] , [ 2 ] ) if not iIIii1IIi : print "Your program is having issues with list intersection. Expected [2], but it output %s" % ( str ( O0 [ 1 ] ) ) oooo = False o0OO00 = iI11I1II1I1I ( O0 [ 2 ] , [ 1 , 3 ] ) if not o0OO00 : print "Your program is having issues with list symmetric difference. Expected [1, 3], but it output %s" % ( str ( O0 [ 2 ] ) ) oooo = False if not ( False == O0 [ 3 ] ) : print "Your program is having issues with list equality. Expected False, but it output True" oooo = False if oooo : ii = [ 1 , 2 ] oOOo = [ 1 , 2 ] oo = module2_assignment2 . test_all_methods ( ii , oOOo ) o0O = iI11I1II1I1I ( oo [ 0 ] , [ 1 , 2 ] ) oooo = True if not o0O : print "Your program is having issues with list union. Expected [1, 2], but it output %s" % ( str ( oo [ 0 ] ) ) oooo = False iIIii1IIi = iI11I1II1I1I ( oo [ 1 ] , [ 1 , 2 ] ) if not iIIii1IIi : print "Your program is having issues with list intersection. Expected [1,2], but it output %s" % ( str ( oo [ 1 ] ) ) oooo = False o0OO00 = iI11I1II1I1I ( oo [ 2 ] , [ ] ) if not o0OO00 : print "Your program is having issues with list symmetric difference. Expected [], but it output %s" % ( str ( oo [ 2 ] ) ) oooo = False if not ( True == oo [ 3 ] ) : print "Your program is having issues with list equality. Expected True, but it output False" oooo = False if oooo : ii = ( 1 , 2 ) oOOo = ( 2 , 3 ) i1iII1IiiIiI1 = module2_assignment2 . test_all_methods ( ii , oOOo ) o0O = iI11I1II1I1I ( i1iII1IiiIiI1 [ 0 ] , ( 1 , 2 , 3 ) ) oooo = True if not o0O : print "Your program is having issues with tuple union. Expected (1, 2, 3), but it output %s" % ( str ( i1iII1IiiIiI1 [ 0 ] ) ) oooo = False iIIii1IIi = iI11I1II1I1I ( i1iII1IiiIiI1 [ 1 ] , ( 2 ) ) if not iIIii1IIi : print "Your program is having issues with tuple intersection. Expected (2), but it output %s" % ( str ( i1iII1IiiIiI1 [ 1 ] ) ) oooo = False o0OO00 = iI11I1II1I1I ( i1iII1IiiIiI1 [ 2 ] , ( 1 , 3 ) ) if not o0OO00 : print "Your program is having issues with tuple symmetric difference. Expected (1,3), but it output %s" % ( str ( i1iII1IiiIiI1 [ 2 ] ) ) oooo = False if not ( False == i1iII1IiiIiI1 [ 3 ] ) : print "Your program is having issues with tuple equality. Expected True, but it output False" oooo = False if oooo : ii = { 'a' : 1 , 'b' : 2 } oOOo = { 'b' : 2 , 'c' : 3 } iIiiiI1IiI1I1 = module2_assignment2 . test_all_methods ( ii , oOOo ) o0O = iI11I1II1I1I ( iIiiiI1IiI1I1 [ 0 ] , { 'a' : 1 , 'c' : 3 , 'b' : 2 } ) oooo = True if not o0O : print "Your program is having issues with dictionary union. Expected {'a': 1, 'c': 3, 'b': 2}, but it output %s" % ( str ( iIiiiI1IiI1I1 [ 0 ] ) ) oooo = False iIIii1IIi = iI11I1II1I1I ( iIiiiI1IiI1I1 [ 1 ] , { 'b' : 2 } ) if not iIIii1IIi : print "Your program is having issues with dictionary intersection. Expected {'b': 2}, but it output %s" % ( str ( iIiiiI1IiI1I1 [ 1 ] ) ) oooo = False o0OO00 = iI11I1II1I1I ( iIiiiI1IiI1I1 [ 2 ] , { 'a' : 1 , 'c' : 3 } ) if not o0OO00 : print "Your program is having issues with dictionary symmetric difference. Expected {'a': 1,'c':3}, but it output %s" % ( str ( iIiiiI1IiI1I1 [ 2 ] ) ) oooo = False if not ( False == iIiiiI1IiI1I1 [ 3 ] ) : print "Your program is having issues with dictionary equality. Expected True, but it output False" oooo = False if oooo : print 435271877226384903485 if 54 - 54 : i1 - o0 * i1oOo0OoO * iIIIiiIIiiiIi % Oo def iI11I1II1I1I ( a , b ) : o0OoOoOO00 = True if type ( b ) is int : if not b in a : o0OoOoOO00 = False if len ( a ) > 1 : o0OoOoOO00 = False else : for I11i in a : if not I11i in b : o0OoOoOO00 = False break for I11i in b : if not I11i in a : o0OoOoOO00 = False break return o0OoOoOO00 if 34 - 34 : iii1I1I / O00oOoOoO0o0O . O0oo0OO0 + Oo0ooO0oo0oO . I1i1iI1i - II def O0O ( ) : oo000 ( ) if 67 - 67 : iiI1iIiI . ooo0Oo0 * i1OOooo0000ooo - oo00000o0 % O0o0o00o0Oo0 / ii11 if __name__ == "__main__" : O0O ( ) # dd678faae9ac167bc83abf78e5cb2f3f0688d3a3 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!