<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">When printing the rows of the array/canvas you might add \n to the end of each row and print the canvas all at once rather than a print statement for each row. </div>

</div><div class="gmail_extra"><br clear="all"><div><div>Vincent Davis</div><div>720-301-3003<span></span><span></span></div></div>
<br><br><div class="gmail_quote">On Sat, Jan 4, 2014 at 3:10 PM, Vincent Davis <span dir="ltr"><<a href="mailto:vincent@vincentdavis.net" target="_blank">vincent@vincentdavis.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">You might think about using an array to represent the canvas. Starting with it filled with "" and then for each point change it to "X".</div>


<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">The print the rows of the array.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">


You can make the array/canvas arbitrarily large and then plot multiple different paths onto the same array.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div></div><div class="gmail_extra">


<br clear="all"><div><div>Vincent Davis</div><div><a href="tel:720-301-3003" value="+17203013003" target="_blank">720-301-3003</a><span></span><span></span></div></div>
<br><br><div class="gmail_quote"><div><div class="h5">On Sat, Jan 4, 2014 at 9:15 AM, Jason Friedman <span dir="ltr"><<a href="mailto:jsf80238@gmail.com" target="_blank">jsf80238@gmail.com</a>></span> wrote:<br></div>

</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div dir="ltr"><font face="arial, helvetica, sans-serif">I am teaching Python to a class of six-graders as part of an after-school enrichment.  These are average students.  We wrote a non-GUI "rocket lander" program:  you have a rocket some distance above the ground, a limited amount of fuel and a limited burn rate, and the goal is to have the rocket touch the ground below some threshold velocity.<br>




<br>I thought it would be neat, after a game completes, to print a graph showing the descent.<br>
<br>Given these measurements:</font><div><div><font face="arial, helvetica, sans-serif">measurement_dict = { # time, height</font></div><div><font face="arial, helvetica, sans-serif">    0: 10,</font></div><div><font face="arial, helvetica, sans-serif">    1: 9,</font></div>



<div><font face="arial, helvetica, sans-serif">    2: 9,</font></div><div><font face="arial, helvetica, sans-serif">    3: 8,</font></div><div><font face="arial, helvetica, sans-serif">    4: 8,</font></div><div><font face="arial, helvetica, sans-serif">    5: 7,</font></div>



<div><font face="arial, helvetica, sans-serif">    6: 6,</font></div><div><font face="arial, helvetica, sans-serif">    7: 4,</font></div><div><font face="arial, helvetica, sans-serif">    8: 5,</font></div><div><font face="arial, helvetica, sans-serif">    9: 3,</font></div>



<div><font face="arial, helvetica, sans-serif">    10: 2,</font></div><div><font face="arial, helvetica, sans-serif">    11: 1,</font></div><div><font face="arial, helvetica, sans-serif">    12: 0,</font></div><div><font face="arial, helvetica, sans-serif">}</font></div>



<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">The easiest solution is to have the Y axis be time and the X axis distance from the ground, and the code would be:<br>



</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">for t, y in measurement_dict.items():</font></div><div><font face="arial, helvetica, sans-serif">    print("X" * y)</font></div>



<div><font face="arial, helvetica, sans-serif"><br></font></div><font face="arial, helvetica, sans-serif">That output is not especially intuitive, though.  A better visual would be an X axis of time and Y axis of distance:<br>




<br></font><div><div><font face="arial, helvetica, sans-serif">max_height = max(measurement_dict.values())</font></div><div><font face="arial, helvetica, sans-serif">max_time = max(measurement_dict.keys())</font></div><div>



<font face="arial, helvetica, sans-serif">for height in range(max_height, 0, -1):</font></div><div><font face="arial, helvetica, sans-serif">    row = list(" " * max_time)</font></div><div><font face="arial, helvetica, sans-serif">    for t, y in measurement_dict.items():</font></div>



<div><font face="arial, helvetica, sans-serif">        if y >= height:</font></div><div><font face="arial, helvetica, sans-serif">            row[t] = 'X'</font></div><div><font face="arial, helvetica, sans-serif">    print("".join(row))</font></div>



<div><font face="arial, helvetica, sans-serif"><br></font></div></div><div><font face="arial, helvetica, sans-serif">My concern is whether the average 11-year-old will be able to follow such logic.  Is there a better approach?</font></div>




</div></div>
<br></div></div><span class="HOEnZb"><font color="#888888">--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
<br></font></span></blockquote></div><br></div>
</blockquote></div><br></div>