Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the following coding Using Python. Only modify this file. Insert python code in after the line ######### YOUR CODE STARTS HERE ################ def conditionalComparison(a,b):
Complete the following coding Using Python. Only modify this file. Insert python code in after the line ######### YOUR CODE STARTS HERE ################
def conditionalComparison(a,b): result = None #Below compare the value in a against b, return 1 if a is greater than b, 0 if they are equal, and -1 if b is greater than a #Note: you can use the built-in comparison symbols (<,>,==) to solve this ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ return result def loop(a,b): result = [] #Place each value between a and b(both integers) into the list variable result #Note: you can presume a < b and do not include a or b ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ return result def dataStructureIteration(a,b): result = None #Below write code that returns the first index in a, which will be a list, where b is found #Note: to make this worth while and get you ready for the next exercise you might want to # use a for or while loop #Note: you can use the break, pass, continue keywords here to complete this function or # remove the last line ('return result') and return from the loop, but that is not # the cleanest way to write code ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ return result def enumeration(a): result = {} #Convert a into the dictionary result, the indexes of a are the keys and the values at the indexes # of a are the values associated with the keys in result. Using enumerate will make this easy ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ return result def breakContinuePass(a,b): result = [] #For each value in the range(a,b+1) do the perform the following 4 actions: # 1) if the value equals a then continue through the loop and do nothing # 2) if the value is greater than a and less than b, add it to result # 3) if the value equals b, break from the loop # 4) if the value is less than a or greater than b, pass -- since if you code it write it is impossible ######### YOUR CODE STARTS HERE ################ ######### YOUR CODE ENDS HERE ################ return result def test_all_methods(int0,int1,list0): result = [] result.append(conditionalComparison(int0,int1)) result.append(loop(int0,int1)) result.append(dataStructureIteration(list0,int0)) result.append(enumeration(list0)) result.append(breakContinuePass(int0,int1)) return result
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