''' DS2000 Spring 2020 Source code from class - iterating over lists ''' def main(): input() ########################################################################### # If you are sitting on the left side (from Laney's pov), what will print? ########################################################################### lst = [1, 2, 3] for i in range(len(lst)): print(lst[i]) input() ########################################################################### # If you are sitting in the middle of the room, what will print? ########################################################################### lst = [1, 2, 3] for i in range(len(lst)): print(i) input() ########################################################################### # If you are sitting on the right side (from Laney's pov), what will print? ########################################################################### lst = [1, 2, 3] for i in range(len(lst)): print(len(lst)) input() ########################################################################### # If you are sitting on the left side (from Laney's pov), what will print? ########################################################################### lst = [1, 2, 3] for i in range(len(lst)): print(lst[i] * 2) input() ########################################################################### # If you are sitting in the middle, what will print? ########################################################################### lst = [1, 2, 3] for i in range(len(lst)): print(lst[0]) input() ########################################################################### # If you are sitting on the right side (from Laney's pov), what will print? ########################################################################### lst = [1, 2, 3] for i in range(len(lst)): print(lst[i] * i) ######################################################### # # # That's it for basic iteration! # # Now, what happens when we modify a list? # # # ######################################################### input() ########################################################################### # If you are sitting on the left side, what will be stored in lst? ########################################################################### lst = [1, 4, 9, 16, 25] for i in range(len(lst)): lst[i] = (lst[i] % 2 == 1) print(lst) input() ########################################################################### # If you are sitting in the middle, what will be stored in lst? ########################################################################### lst = [1, 4, 9, 16] for i in range(len(lst)): lst[i] = i print(lst) input() ########################################################################### # If you are sitting on the right side, what will be stored in lst? ########################################################################### lst = [2, 4, 6, 8] for i in range(len(lst)): lst[i] = lst[i] + 1 print(lst) main()