QUIZ 2 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 ... >>> from quiz_2 import * >>> L = [] >>> apply_pattern_to_list(L) {} >>> L [] >>> L = [1] >>> apply_pattern_to_list(L) {} >>> L [1] >>> L = [1, 2, 1, 2, 1, 2, 3] >>> apply_pattern_to_list(L) {6: 3} >>> L [1, 2, 1, 2, 1, 2] >>> L = [1, 2, 1, 2, 1, 2, 3] >>> apply_pattern_to_list(L, from_start=False) {-3: 1, -4: 2, -5: 1, -6: 2, -7: 1} >>> L [2, 3] >>> L = [1, 3, 2, 0, 0, -2, -2, 1, 5, -4] >>> apply_pattern_to_list(L, '++-') {2: 2, 3: 0, 4: 0, 5: -2, 6: -2, 7: 1} >>> L [1, 3, 5, -4] >>> L = [1, 3, 2, 0, 0, -2, -2, 1, 5, -4] >>> apply_pattern_to_list(L, '++-', False) {-2: 5, -3: 1, -4: -2, -5: -2, -6: 0, -7: 0, -8: 2, -9: 3, -10: 1} >>> L [-4] >>> L = [-11, -2, -3, 11, -11, -12, 12, -7, 14, -5, 15, -1, 11, -10, 11] >>> apply_pattern_to_list(L, '---+') {1: -2, 2: -3, 3: 11, 4: -11, 6: 12, 7: -7, 8: 14, 9: -5, 10: 15, 11: -1, 12: 11, 13: -10, 14: 11} >>> L [-11, -12] >>> L = [-11, -2, -3, 11, -11, -12, 12, -7, 14, -5, 15, -1, 11, -10, 11] >>> apply_pattern_to_list(L, '---+', False) {-2: -10, -3: 11, -4: -1, -7: 14, -9: 12, -12: 11, -13: -3, -14: -2, -15: -11} >>> L [-11, -12, -7, -5, 15, 11] Date: Trimester 3, 2024. 2 COMP9021 PRINCIPLES OF PROGRAMMING >>> L = [0, -4, 4, 4, 2, -2, 1, 3, -3, -4, -4, -2, -3, 0, 1, 2, -4, 3, -1, 1] >>> apply_pattern_to_list(L, '-+') {3: 4, 5: -2, 6: 1, 9: -4, 10: -4, 14: 1, 15: 2} >>> L [0, -4, 4, 2, 3, -3, -2, -3, 0, -4, 3, -1, 1] >>> L = [0, -4, 4, 4, 2, -2, 1, 3, -3, -4, -4, -2, -3, 0, 1, 2, -4, 3, -1, 1] >>> apply_pattern_to_list(L, '-+', False) {-2: -1, -7: 0, -8: -3, -9: -2, -10: -4, -11: -4, -12: -3, -15: -2, -17: 4, -18: 4} >>> L [0, -4, 2, 1, 3, 1, 2, -4, 3, 1] 51作业君版权所有