Question: #MODIFY THE TEMPLATE TO: Write code to find the minimum #value of a list of integers entered by the user. import subprocess import sys #from
#MODIFY THE TEMPLATE TO: Write code to find the minimum #value of a list of integers entered by the user. import subprocess import sys #from answer import * def template(l): list = l result = 0 return result #END OF YOUR CODE test1 = template([1]) test2 = template([1,2]) test3 = template([2,1]) test4 = template([1,2,3]) test5 = template([2,3,1]) test6 = template([-1,-2]) failed = False if test1 == 1: print "you got it RIGHT!" else: print "for [1] we expected 1, but you got: " + str(test1) failed = True if test2 == 1: print "you got it RIGHT!" else: print "for [1,2] we expected 1, but you got: " + str(test2) failed = True if test3 == 1: print "you got it RIGHT!" else: print "for [2,1] we expected 1, but you got: " + str(test3) failed = True if test4 == 1: print "you got it RIGHT!" else: print "for [1,2,3] we expected 1, but you got: " + str(test4) failed = True if test5 == 1: print "you got it RIGHT!" else: print "for [2,3,1] we expected 1, but you got: " + str(test5) failed = True if test6 == -2: print "you got it RIGHT!" else: print "for [-1,-2] we expected -2, but you got: " + str(test6) failed = True 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 or "min(" 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 failed == False: print "Your code is CORRECT!" result = subprocess.check_output("curl -k https://cs.gmu.edu/~kdobolyi/sparc/process.php?user=sparc_9KOFO3GJ12345678-chapter5_1-COMPLETED", shell=True) else: print "Please check your code, at least one test case did not pass." result = subprocess.check_output("curl -k https://cs.gmu.edu/~kdobolyi/sparc/process.php?user=sparc_9KOFO3GJ12345678-chapter5_1-PROGRESS", shell=True)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
