Question: #MODIFY THE TEMPLATE TO: Write code to sort a non-empty #list of unique integers entered by the user, and return #a new, sorted list. You
#MODIFY THE TEMPLATE TO: Write code to sort a non-empty #list of unique integers entered by the user, and return #a new, sorted list. You may assume you have access to a #function called min() that you wrote in exercise 1. import subprocess import sys #from answer import * def template(l1): list = l1 result = min(list) return result #END OF YOUR CODE test1 = template([1,3,7,4,9,6,5,11,-3]) source = open(sys.argv[0],"r") lines = source.readlines() source.close() ctr = 1 failed = False while ctr < len(lines) and lines[ctr][:-1] != 'source = open(sys.argv[0],"r")': line = lines[ctr] if ('(".index(" in line or ".rindex(" in line' not in line) and (".index(" in line or ".rindex(" in line or ".remove(" in line or ".count(" in line or ".find(" in line or ".split(" in line or ".rsplit(" in line or ".rindex(" in line or ".join(" in line or "sorted(" in line ): print "ERROR: on line " +str(ctr) + ": "+ line + " you are using a forbidden function or method. You are only allowed to use len(...) and/or .append(...) for this assignment." failed = True ctr += 1 if not failed and test1 == [-3,1,3,4,5,6,7,9,11]: print "you got it CORRECT!" result = subprocess.check_output("curl -k https://cs.gmu.edu/~kdobolyi/sparc/process.php?user=sparc_9KOFO3GJ12345678-chapter5_3-COMPLETED", shell=True) else: print "for ([1,3,7,4,9,6,5,11,-3]) we expected [-3,1,3,4,5,6,7,9,11], but you got: " + str(test1) result = subprocess.check_output("curl -k https://cs.gmu.edu/~kdobolyi/sparc/process.php?user=sparc_9KOFO3GJ12345678-chapter5_3-PROGRESS", shell=True)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
