#------------------------------------------- for i in range(n): for j in range(n): print i, j #------------------------------------------- while n > 1: print n n = n/2 #------------------------------------------- for i in range(n): for j in range(10): print i, j #------------------------------------------- i = 0 while i < n: print i i = i + 1 #------------------------------------------- while n > 0 print n #-------------------------------------------
0 1 2 3 4 5 6 7 8 L = [10, 17, 44, 45, 46, 58, 67, 99, 122] x = 99
L = [9, 35, 18, 200, 0, 6, 43, 21]Which of the following represents L after 3 iterations of the outer loop in the algorithm:
A. [0, 6, 9, 18, 21, 35, 43, 200] B. [0, 6, 9, 200, 18, 35, 43, 21] C. [0, 9, 35, 18, 200, 6, 43, 21] D. [0, 6, 9, 35, 200, 18, 43, 21]
L = [22, 41, 56, 7, 79, 75, 89]Which value in the list would be the first one to be swapped?
L = [22, 41, 56, 7, 79, 75, 89]Show how the list would change after completing one iteration of the outer loop of the algorithm.
ls = [[1, "dog"], [3, "fish"], [2, "cat"]]What are the value and type of the following expressions:
(1) len(ls) (2) ls[1] (3) ls[1][1] (4) ls[1][0] < ls[2][0] (5) ls[2][1] + ls[1][1]