Hey , I am getting error in this code .Can anyone explain me where…

Question Answered step-by-step Hey , I am getting error in this code .Can anyone explain me where… Hey , I am getting error in this code .Can anyone explain me where I am getting wrong and explain it. def getInput():   ”’Get the size of list from the users”’   inp = int(input(“Enter a number between 0 and 100 “))   return inpdef getNum():   ”’Getting a number to form sum”’   n = int(input(“Enter a number in any range “))   return ndef getlist(inp):   ”’Get sorted list from values ranges from o to 100”’   import random   lst = random.sample(list(range(0,101)), inp)   srtlst = sorted(lst)   return srtlstdef binsearch(x,nums,low,high):   ”’Conduct binary search”’   if low > high:       return -1  # no place left to look , so return -1   mid = int((low + high)/2)   if mid >=len(nums):       return -1   item = nums[mid]   if item == x:       return mid   elif x < mid: # Look in lower half       return binsearch(x,nums,low,mid-1)   else:        # look in upper half       return binsearch(x,nums,mid+1,high)      def printsummary(n,srtlst):       '''print two number sum to n or print cannot find'''       for i in range(len(srtlst) - 1):           num = n - srtlst[i]           result = binsearch(num,srtlst[(i + 1):],0,len(srtlst[(i+1):]))           if result != 1:               print(n,"=",srtlst[i],"+",num)               break           else:               print("We can not find the number",n)               breakdef main():   inp = getInput()   n = getNum()   srtlst = getlist(inp)   printsummary(n,srtlst)main() Computer Science Engineering & Technology Python Programming DSC 430 Share QuestionEmailCopy link Comments (0)

Leave a Comment

Your email address will not be published. Required fields are marked *