Rather than writing a program, in this practice HW you will walk through the execution of a program on paper. You don’t need to run the program to complete the assignment.
Take a look at loopy.py and the output from a sample run. Each line of code in loopy.py is given a line number to the left. Given this sample run, in what order are the statements executed? List the line numbers in the order that they are executed. Hint: not all line numbers need to be included, and some line numbers may appear multiple times.
Make sure you can answer the following questions:
Order that the lines are executed:
34, 35, 36 get_area(+,+)
5, 6, 7
36, 38 rectangle_outline
21, 22, 24, 25 draw_line(25)
16, 25 * (17, 18), 19
23 * ( 22, 24, 28, 29, 23 * (30, 31), 32 )
22, 24, 25 draw_line(25)
16, 25 * (17, 18), 19
40 get_area(-,+)
5, 6, 8, 9, 10, 11, 14
41 get_area(+,-)
5, 6, 8, 9, 10, 12, 13, 14
43, 44 draw_line
16, 17, 19
43, 44, 16, 1 * (17, 18), 19
43, 44, 16, 2 * (17, 18), 19
43, 44, 16, 3 * (17, 18), 19
43, 44, 16, 4 * (17, 18), 19
43
Questions:
You’ll learn significantly less from watching me solve the HW if you haven’t attempted the HW yourself first.
While it’s an achievement to finish the HW no matter how long it takes, you might experience “diminishing returns” if you work longer than the DNF (Did Not Finish) time. Thus, it might be strategic to stop working at the DNF time and watch my solution.
After watching my solution, I recommend that you repeat the HW if you have not achieved at least Av (Average) performance. If so, be sure to:
Feel free to keep trying until you make Rx if that’s of interest to you.