Question: lease do the slide with heading hand in for reference activities and scope ry Acivi 00 00000000000 000 00000000o000 ACTIVITY: References 1 1 print ('Example:

 lease do the slide with heading hand in for reference activitiesand scope ry Acivi 00 00000000000 000 00000000o000 ACTIVITY: References 1 1print ('Example: Copying References') 2 [1, 2, 3] 3 4 print ('before', x, 5 y [0] 6 print ('after ', x, y) y)100 1. Predict the console output. 2. Draw the frame and heapdiagram, showing all the variables and values in the snippet. 3. Question:Does the change to y on line 5 affect x? Explain why

lease do the slide with heading hand in for reference activities and scope ry Acivi 00 00000000000 000 00000000o000 ACTIVITY: References 1 1 print ('Example: Copying References') 2 [1, 2, 3] 3 4 print ('bef ore', x, 5 y [0] 6 print ('after ', x, y) y) 100 1. Predict the console output. 2. Draw the frame and heap diagram, showing all the variables and values in the snippet. 3. Question: Does the change to y on line 5 affect x? Explain why or why not. ACTIVITY: References 2 1 print ('Example: Copying Lists') [1, 2, 3] x[:] # copies the list y %3! print ('before', x, y) 5 y [0] print ('after ', x, y) 100 1. Predict the console output. 2. Draw the frame and heap diagram, showing all the variables and values in the snippet. 3. Question: Does the change to y on line 5 affect x? Explain why or why not. Handin for References Activities Collect your one sentence answers, and place them in a file named lab02-responses.txt Example: 1 | Activity References 1: There is only one list, with two references to it (variables x and y), and the assignment on line 5 changed this list. 6 | Activity References 2: Line 3 created a copy of the list, and the assignment 8 on line 5 changes the copy, but not the statement original. 10 11 (etc) Hand-in the file lab02-responses.txt Scope ACTIVITY Download the files scope.py and test_scope.py from Lab02 on Moodle. Study the code in both files. Run the test script. Observe the errors! Don't fix them yet. Add at least 4 new test cases to the test script. Re-order your tests. You'll get different reports! Copy/paste the output of your test script, showing errors to the 1lab02-transcript.txt file. escope.py def find_duplicates (alist): Purpose: Return a list of duplicate values found in alist. Pre: alist: a list of values Post: None Return: A list of duplicates from alist [] uniques for item in alist: if item in uniques: duplicates.append (item) else: uniques.append (item) return duplicates # a global [] duplicates #test scope.py # test case inputs = [1, 2, 3] expected [] reason = 'Longer list with no duplicates' result = scope.find_duplicates(inputs) if result != expected: %3D print('Error in find_duplicates: expected', expected, 'but obtained', result, '--', reason) print('*** Test script finished ***') lease do the slide with heading hand in for reference activities and scope ry Acivi 00 00000000000 000 00000000o000 ACTIVITY: References 1 1 print ('Example: Copying References') 2 [1, 2, 3] 3 4 print ('bef ore', x, 5 y [0] 6 print ('after ', x, y) y) 100 1. Predict the console output. 2. Draw the frame and heap diagram, showing all the variables and values in the snippet. 3. Question: Does the change to y on line 5 affect x? Explain why or why not. ACTIVITY: References 2 1 print ('Example: Copying Lists') [1, 2, 3] x[:] # copies the list y %3! print ('before', x, y) 5 y [0] print ('after ', x, y) 100 1. Predict the console output. 2. Draw the frame and heap diagram, showing all the variables and values in the snippet. 3. Question: Does the change to y on line 5 affect x? Explain why or why not. Handin for References Activities Collect your one sentence answers, and place them in a file named lab02-responses.txt Example: 1 | Activity References 1: There is only one list, with two references to it (variables x and y), and the assignment on line 5 changed this list. 6 | Activity References 2: Line 3 created a copy of the list, and the assignment 8 on line 5 changes the copy, but not the statement original. 10 11 (etc) Hand-in the file lab02-responses.txt Scope ACTIVITY Download the files scope.py and test_scope.py from Lab02 on Moodle. Study the code in both files. Run the test script. Observe the errors! Don't fix them yet. Add at least 4 new test cases to the test script. Re-order your tests. You'll get different reports! Copy/paste the output of your test script, showing errors to the 1lab02-transcript.txt file. escope.py def find_duplicates (alist): Purpose: Return a list of duplicate values found in alist. Pre: alist: a list of values Post: None Return: A list of duplicates from alist [] uniques for item in alist: if item in uniques: duplicates.append (item) else: uniques.append (item) return duplicates # a global [] duplicates #test scope.py # test case inputs = [1, 2, 3] expected [] reason = 'Longer list with no duplicates' result = scope.find_duplicates(inputs) if result != expected: %3D print('Error in find_duplicates: expected', expected, 'but obtained', result, '--', reason) print('*** Test script finished ***')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!