[15, 99, 4, 30, 3, 82, 7, 42]
def oneLoop(ls): print "in oneLoop" for j in range(len(ls)-1): if ls[j] > ls[j+1]: tmp = ls[j+1] ls[j+1] = ls[j] ls[j] = tmp(1) Given the list ls = [17, 4, 19, 3, 11, 8], what is ls after one call to oneLoop(ls)?
(2) Given the following main function, trace through its execution showing all program output and drawing the stack right before the call to function oneLoop returns:
def main( ): print "in main" my_list = [6, 8, 19, 3, 7] print my_list oneLoop(my_list) print my_list
def main(): n = 5 ans = factorial(n) print ans def factorial(x): if x == 0: return 1 else: return x * factorial(x-1) main()