Skip to content

Commit 6386153

Browse files
author
Philip Guo
committed
bam
1 parent f681225 commit 6386153

2 files changed

Lines changed: 58 additions & 6 deletions

File tree

‎v3/commentary-bubbles-demo.html‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131
<body>
3232

3333

34-
35-
3634
<!--<div id="listSumDiv"></div>-->
3735

3836
<div id="listSumDiv"><div class="ExecutionVisualizer"><table border="0" class="visualizer"> <tbody><tr> <td valign="top" id="left_pane"> <center> <div id="pyCodeOutputDiv"><table id="pyCodeOutput"><tr><td id="gutterTD" valign="top" rowspan="9"><svg id="leftCodeGutterSVG" style="height: 205px;"><polygon id="prevLineArrow" points="0,3 12,3 12,0 18,5 12,10 12,7 0,7" fill="#c9e6ca" style="display: inline;" transform="translate(0, 51)"></polygon><polygon id="curLineArrow" points="0,3 12,3 12,0 18,5 12,10 12,7 0,7" fill="#e93f34" transform="translate(0, 62)" style=""></polygon></svg></td><td class="lineNo" id="lineNo1">1</td><td class="cod" id="v1__cod1" style="">def&nbsp;listSum(numbers):</td></tr><tr><td class="lineNo" id="lineNo2">2</td><td class="cod" id="v1__cod2" style="">&nbsp;&nbsp;if&nbsp;not&nbsp;numbers:</td></tr><tr><td class="lineNo" id="lineNo3">3</td><td class="cod" id="v1__cod3" style="">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0</td></tr><tr><td class="lineNo" id="lineNo4">4</td><td class="cod" id="v1__cod4" style="">&nbsp;&nbsp;else:</td></tr><tr><td class="lineNo" id="lineNo5">5</td><td class="cod" id="v1__cod5" style="">&nbsp;&nbsp;&nbsp;&nbsp;(f,&nbsp;rest)&nbsp;=&nbsp;numbers</td></tr><tr><td class="lineNo" id="lineNo6">6</td><td class="cod" id="v1__cod6" style="">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;f&nbsp;+&nbsp;listSum(rest)</td></tr><tr><td class="lineNo" id="lineNo7">7</td><td class="cod" id="v1__cod7" style=""></td></tr><tr><td class="lineNo" id="lineNo8">8</td><td class="cod" id="v1__cod8" style="">myList&nbsp;=&nbsp;(1,&nbsp;(2,&nbsp;(3,&nbsp;None)))</td></tr><tr><td class="lineNo" id="lineNo9">9</td><td class="cod" id="v1__cod9" style="">total&nbsp;=&nbsp;listSum(myList)</td></tr></table></div> <div id="editCodeLinkDiv"> <a id="editBtn" href="http://pythontutor.com/visualize.html#code=def+listSum(numbers)%3A%0A++if+not+numbers%3A%0A++++return+0%0A++else%3A%0A++++(f,+rest)+%3D+numbers%0A++++return+f+%2B+listSum(rest)%0A%0AmyList+%3D+(1,+(2,+(3,+None)))%0Atotal+%3D+listSum(myList)">Edit code</a> </div> <div id="executionSlider" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" style="font-size: 0.9em;"><a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 77.77777777777779%; width: 0.8em; height: 1.4em;"></a></div> <div id="vcrControls"> <button id="jmpFirstInstr" ,="" type="button">&lt;&lt; First</button> <button id="jmpStepBack" ,="" type="button">&lt; Back</button> <span id="curInstr">Step 15 of 18</span> <button id="jmpStepFwd" ,="" type="button">Forward &gt;</button> <button id="jmpLastInstr" ,="" type="button">Last &gt;&gt;</button> </div> <div id="errorOutput" style="display: none;"></div> </center> <div id="legendDiv"><svg id="prevLegendArrowSVG"><polygon points="0,3 12,3 12,0 18,5 12,10 12,7 0,7" fill="#c9e6ca"></polygon></svg> line that has just executed<p style="margin-top: 4px"><svg id="curLegendArrowSVG"><polygon points="0,3 12,3 12,0 18,5 12,10 12,7 0,7" fill="#e93f34"></polygon></svg> next line to execute</p></div> <div id="progOutputs"> Program output:<br> <textarea id="pyStdout" cols="50" rows="13" wrap="off" readonly=""></textarea> </div> </td> <td valign="top"> <div id="dataViz"> <table id="stackHeapTable"> <tbody><tr> <td id="stack_td"> <div id="globals_area"> <div id="stackHeader">Frames</div> <div class="stackFrame" id="v1__globals" style="display: block;"><div id="v1__globals_header" class="stackFrameHeader">Global variables</div><table class="stackFrameVarTable" id="v1__global_table"><tr id="v1__globals__listSum"><td class="stackFrameVar">listSum</td><td class="stackFrameValue" data-curvalue="object:REF,1"><div class="stack_pointer" id="v1__global__listSum">&nbsp;</div><div style="position: absolute; height: 6px; width: 6px; left: 716px; top: 82px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 681.65px; top: 36.875px; z-index: 0;" width="157.7" height="69.75" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 37.35 48.125 C 68.85 24.875 68.85 24.875 120.35 21.625000000000004" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M120.35,21.625000000000004 L110.59119347905715,25.750008519603746 L114.8609953438376,21.972603056125227 L110.14878958944323,18.764002593578887 L120.35,21.625000000000004" class="" stroke="#cccccc" fill="#cccccc"></path></svg></td></tr><tr id="v1__globals__myList"><td class="stackFrameVar">myList</td><td class="stackFrameValue" data-curvalue="object:REF,2"><div class="stack_pointer" id="v1__global__myList">&nbsp;</div><div style="position: absolute; height: 6px; width: 6px; left: 716px; top: 107px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 681.65px; top: 93.25px; z-index: 0;" width="157.7" height="40.5" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 37.35 16.75 C 88.85 10.25 88.85 10.25 120.35 23.75" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M120.35,23.75 L112.53598560726692,16.595198879761902 L115.29431435933272,21.584349358102596 L109.77970297212477,23.02970787697481 L120.35,23.75" class="" stroke="#cccccc" fill="#cccccc"></path></svg></td></tr></table></div></div> <div id="stack"> <div class="stackFrame" id="v1__stack0"><div class="stackFrameHeader">listSum</div><table class="stackFrameVarTable"><tr id="v1__listSum_f1__numbers"><td class="stackFrameVar">numbers</td><td class="stackFrameValue" data-curvalue="object:REF,2"><div class="stack_pointer" id="v1__listSum_f1__numbers">&nbsp;</div></td></tr><tr id="v1__listSum_f1__f"><td class="stackFrameVar">f</td><td class="stackFrameValue" data-curvalue="number:1"><span class="numberObj">1</span></td></tr><tr id="v1__listSum_f1__rest"><td class="stackFrameVar">rest</td><td class="stackFrameValue" data-curvalue="object:REF,3"><div class="stack_pointer" id="v1__listSum_f1__rest">&nbsp;</div></td></tr><div style="position: absolute; height: 6px; width: 6px; left: 719px; top: 180.5px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 686px; top: 85.375px; z-index: 0;" width="152" height="129.75" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 36 98.125 C 66 54.875 66 54.875 116 31.625000000000004" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M116,31.625000000000004 L108.41004049507323,39.01705754263126 L111.01340863726838,33.94532467149113 L105.45690000408452,32.670486717336466 L116,31.625000000000004" class="" stroke="#cccccc" fill="#cccccc"></path></svg><div style="position: absolute; height: 6px; width: 6px; left: 719px; top: 230.5px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 651.8px; top: 64.57499999999999px; z-index: 0;" width="296.4" height="221.35" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 70.2 168.92499999999998 C 138.2 100.675 138.2 100.675 226.2 52.425000000000004" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M226.2,52.425000000000004 L219.11478569241555,60.3021656206786 L221.37753028850594,55.06957669235031 L215.74896081124243,54.164476896958895 L226.2,52.425000000000004" class="" stroke="#cccccc" fill="#cccccc"></path></svg></table></div><div class="stackFrame" id="v1__stack1"><div class="stackFrameHeader">listSum</div><table class="stackFrameVarTable"><tr id="v1__listSum_f2__numbers"><td class="stackFrameVar">numbers</td><td class="stackFrameValue" data-curvalue="object:REF,3"><div class="stack_pointer" id="v1__listSum_f2__numbers">&nbsp;</div></td></tr><tr id="v1__listSum_f2__f"><td class="stackFrameVar">f</td><td class="stackFrameValue" data-curvalue="number:2"><span class="numberObj">2</span></td></tr><tr id="v1__listSum_f2__rest"><td class="stackFrameVar">rest</td><td class="stackFrameValue" data-curvalue="object:REF,4"><div class="stack_pointer" id="v1__listSum_f2__rest">&nbsp;</div></td></tr><div style="position: absolute; height: 6px; width: 6px; left: 719px; top: 305.5px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 651.8px; top: 30.825000000000003px; z-index: 0;" width="296.4" height="363.84999999999997" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 70.2 277.67499999999995 C 138.2 171.92499999999998 138.2 171.92499999999998 226.2 86.175" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M226.2,86.175 L221.4811492327238,95.66090783405451 L222.26110897099562,90.01363744857846 L216.59561066180578,90.64777379713988 L226.2,86.175" class="" stroke="#cccccc" fill="#cccccc"></path></svg><div style="position: absolute; height: 6px; width: 6px; left: 719px; top: 355.5px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 617.6px; top: 8.325000000000003px; z-index: 0;" width="440.79999999999995" height="458.84999999999997" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 104.4 350.17499999999995 C 210.39999999999998 219.42499999999998 210.39999999999998 219.42499999999998 336.4 108.675" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M336.4,108.675 L331.200092795525,117.90597855402393 L332.269120415046,112.30623034997926 L326.5785268955514,112.64849544590069 L336.4,108.675" class="" stroke="#cccccc" fill="#cccccc"></path></svg></table></div><div class="stackFrame" id="v1__stack2"><div class="stackFrameHeader">listSum</div><table class="stackFrameVarTable"><tr id="v1__listSum_f3__numbers"><td class="stackFrameVar">numbers</td><td class="stackFrameValue" data-curvalue="object:REF,4"><div class="stack_pointer" id="v1__listSum_f3__numbers">&nbsp;</div></td></tr><div style="position: absolute; height: 6px; width: 6px; left: 719px; top: 430.5px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#cccccc" stroke="none"></circle></svg></div><svg style="position: absolute; left: 617.6px; top: -25.42500000000001px; z-index: 0;" width="440.79999999999995" height="601.35" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 104.4 458.925 C 210.39999999999998 290.675 210.39999999999998 290.675 336.4 142.425" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#cccccc" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M336.4,142.425 L332.59115748981276,152.31149173026463 L332.8382957339163,146.6159739585163 L327.2571906335194,147.77841357343092 L336.4,142.425" class="" stroke="#cccccc" fill="#cccccc"></path></svg><tr id="v1__listSum_f3__f"><td class="stackFrameVar">f</td><td class="stackFrameValue" data-curvalue="number:3"><span class="numberObj">3</span></td></tr><tr id="v1__listSum_f3__rest"><td class="stackFrameVar">rest</td><td class="stackFrameValue" data-curvalue="object:null"><span class="nullObj">None</span></td></tr></table></div><div class="stackFrame highlightedStackFrame" id="v1__stack3"><div class="stackFrameHeader">listSum</div><table class="stackFrameVarTable"><tr id="v1__listSum_f4__numbers"><td class="stackFrameVar">numbers</td><td class="stackFrameValue" data-curvalue="object:null"><span class="nullObj">None</span></td></tr><tr id="v1__listSum_f4____return__"><td class="stackFrameVar"><span class="retval">Return<br>value</span></td><td class="stackFrameValue" data-curvalue="number:0"><span class="numberObj">0</span></td></tr></table></div></div> </td> <td id="heap_td"> <div id="heap"> <div id="heapHeader">Objects</div> <table class="heapRow"><td class="toplevelHeapObject" id="toplevel_heap_object_1"><div class="heapObject" id="v1__heap_object_1"><div class="funcObj">function listSum(numbers)</div></div></td></table><table class="heapRow"><td class="toplevelHeapObject" id="toplevel_heap_object_2"><div class="heapObject" id="v1__heap_object_2"><div class="typeLabel">tuple</div><table class="tupleTbl"><tbody><tr><td class="tupleHeader">0</td><td class="tupleHeader">1</td></tr><tr><td class="tupleElt"><span class="numberObj">1</span></td><td class="tupleElt"><div id="v1__heap_pointer_src_1">&nbsp;</div><div style="position: absolute; height: 6px; width: 6px; left: 846px; top: 126px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#005583" stroke="none"></circle></svg></div><svg style="position:absolute;left:835.95px;top:111.6px" width="55.099999999999994" height="22.799999999999997" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 13.05 17.4 C 27.549999999999997 11.399999999999999 27.549999999999997 11.399999999999999 42.05 5.4" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#005583" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M42.05,5.4 L34.162774805670125,12.474014329496942 L36.97229700195136,7.513511831906296 L31.4728506559712,6.0114832410714065 L42.05,5.4" class="" stroke="#005583" fill="#005583"></path></svg></td></tr></tbody></table></div></td><td class="toplevelHeapObject" id="toplevel_heap_object_3"><div class="heapObject" id="v1__heap_object_3"><div class="typeLabel">tuple</div><table class="tupleTbl"><tbody><tr><td class="tupleHeader">0</td><td class="tupleHeader">1</td></tr><tr><td class="tupleElt"><span class="numberObj">2</span></td><td class="tupleElt"><div id="v1__heap_pointer_src_2">&nbsp;</div><div style="position: absolute; height: 6px; width: 6px; left: 922px; top: 126px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="#005583" stroke="none"></circle></svg></div><svg style="position:absolute;left:911.95px;top:111.6px" width="55.099999999999994" height="22.799999999999997" pointer-events="none" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml" class="_jsPlumb_connector "><path d="M 13.05 17.4 C 27.549999999999997 11.399999999999999 27.549999999999997 11.399999999999999 42.05 5.4" pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="#005583" stroke-width="1"></path><path pointer-events="all" version="1.1" xmlns="http://www.w3.org/1999/xhtml" d="M42.05,5.4 L34.162774805670125,12.474014329496942 L36.97229700195136,7.513511831906296 L31.4728506559712,6.0114832410714065 L42.05,5.4" class="" stroke="#005583" fill="#005583"></path></svg></td></tr></tbody></table></div><div style="position: absolute; height: 6px; width: 6px; left: 875px; top: 114px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="none"></circle></svg></div></td><td class="toplevelHeapObject" id="toplevel_heap_object_4"><div class="heapObject" id="v1__heap_object_4"><div class="typeLabel">tuple</div><table class="tupleTbl"><tbody><tr><td class="tupleHeader">0</td><td class="tupleHeader">1</td></tr><tr><td class="tupleElt"><span class="numberObj">3</span></td><td class="tupleElt"><span class="nullObj">None</span></td></tr></tbody></table></div><div style="position: absolute; height: 6px; width: 6px; left: 951px; top: 114px;" class="_jsPlumb_endpoint "><svg style="position:absolute;left:0px;top:0px" width="6" height="6" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="3" cy="3" r="3" version="1.1" xmlns="http://www.w3.org/1999/xhtml" style="" fill="none" stroke="none"></circle></svg></div></td></table></div> </td> </tr> </tbody></table> </div> </td> </tr> </tbody></table></div></div>
3937

38+
<p/>
39+
<button id="modeToggleBtn">Enter Edit Mode</button>
40+
4041
</body>
4142
</html>

0 commit comments

Comments
 (0)