Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'output': 0.05; 'canvas': 0.07; 'paths': 0.07; 'canvas.': 0.09; 'received:209.85.219': 0.09; 'rows': 0.09; 'python': 0.11; 'jan': 0.12; 'wrote': 0.14; '-1):': 0.16; '9:15': 0.16; 'arbitrarily': 0.16; 'array.': 0.16; 'be:': 0.16; 'ground,': 0.16; 'threshold': 0.16; '\xc2\xa0you': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'email addr:gmail.com>': 0.22; 'print': 0.22; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'array': 0.29; 'statement': 0.30; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; '"': 0.31; 'concern': 0.31; 'though.': 0.31; 'class': 0.32; 'skip:m 30': 0.32; 'url:python': 0.33; 'to:name:python- list': 0.33; 'received:209.85': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'height': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'starting': 0.37; 'represent': 0.38; 'skip:& 10': 0.38; 'easiest': 0.38; 'filled': 0.38; 'jason': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'visual': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'ground': 0.60; 'such': 0.63; 'teaching': 0.64; 'different': 0.65; 'distance': 0.65; 'fuel': 0.68; 'touch': 0.74; 'goal': 0.75; '10:': 0.84; '11:': 0.84; '12:': 0.84; 'burn': 0.91; 'average': 0.93; 'rocket': 0.95 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=nsNNltmhKff+H5lNIzXiSJ5iASJYsogZdF33BLrU2CA=; b=JWRow1en+9KYJPkrUCavlxfwkxPncKF+idzTbnJniRQaNtqilQg4rC4NQQIwQqJnhJ cbssuNNgQBxpiLAFRheMfwgJdcS/y9BfQbT9xvSoh+FYNYyZUh/upykL1/XyYFpvv20n IQYn0og0HLLIvaal92PFX8C35Xq2cdAvqRVcanONrPgYO2AnatDJmXU6+tFcfekNqB/q 05u8fRBPKsoyvI5assqMNnAYe7n/MPyy78Jl3AWPf4UWeEFSbcTte6ZE1pqavW0gZTPD LubtIxufA8/iqGKOZKikj/Gwr8go2thtgikkgz+Bwhgb8HxtGajWK0Cl8lNL1huHAL0G pWjg== X-Gm-Message-State: ALoCoQkG45eEz11ZoqWn/jLGopxtPNN8CTjfyDq9YdOHTK0mWT91fO/KtU7yhxqt1NqTa4Oefmmr X-Received: by 10.182.49.166 with SMTP id v6mr65524980obn.13.1388873649742; Sat, 04 Jan 2014 14:14:09 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Vincent Davis Date: Sat, 4 Jan 2014 15:13:49 -0700 Subject: Re: Flip a graph To: python-list Content-Type: multipart/alternative; boundary=047d7b5d2ea487fb3204ef2c588d X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 231 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388874076 news.xs4all.nl 2836 [2001:888:2000:d::a6]:50399 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63150 --047d7b5d2ea487fb3204ef2c588d Content-Type: text/plain; charset=UTF-8 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. Vincent Davis 720-301-3003 On Sat, Jan 4, 2014 at 3:10 PM, Vincent Davis wrote: > 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". > The print the rows of the array. > > You can make the array/canvas arbitrarily large and then plot multiple > different paths onto the same array. > > > Vincent Davis > 720-301-3003 > > > On Sat, Jan 4, 2014 at 9:15 AM, Jason Friedman wrote: > >> 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. >> >> I thought it would be neat, after a game completes, to print a graph >> showing the descent. >> >> Given these measurements: >> measurement_dict = { # time, height >> 0: 10, >> 1: 9, >> 2: 9, >> 3: 8, >> 4: 8, >> 5: 7, >> 6: 6, >> 7: 4, >> 8: 5, >> 9: 3, >> 10: 2, >> 11: 1, >> 12: 0, >> } >> >> The easiest solution is to have the Y axis be time and the X axis >> distance from the ground, and the code would be: >> >> for t, y in measurement_dict.items(): >> print("X" * y) >> >> That output is not especially intuitive, though. A better visual would >> be an X axis of time and Y axis of distance: >> >> max_height = max(measurement_dict.values()) >> max_time = max(measurement_dict.keys()) >> for height in range(max_height, 0, -1): >> row = list(" " * max_time) >> for t, y in measurement_dict.items(): >> if y >= height: >> row[t] = 'X' >> print("".join(row)) >> >> My concern is whether the average 11-year-old will be able to follow such >> logic. Is there a better approach? >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> > --047d7b5d2ea487fb3204ef2c588d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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.=C2=A0

Vincent Davis<= /div>
720-301-3003


On Sat, Jan 4, 2014 at 3:10 PM, Vincent = Davis <vincent@vincentdavis.net> wrote:
You might think about using an array to represe= nt the canvas. Starting with it filled with "" and then for each = point change it to "X".
The print the rows of the array.

You can make the array/canvas arbitrarily large and then plot multiple diff= erent paths onto the same array.


Vincent Davis


On Sat, Jan 4, 20= 14 at 9:15 AM, Jason Friedman <jsf80238@gmail.com> wrote:
I am teaching = Python to a class of six-graders as part of an after-school enrichment. =C2= =A0These are average students. =C2=A0We wrote a non-GUI "rocket lander= " program: =C2=A0you have a rocket some distance above the ground, a l= imited amount of fuel and a limited burn rate, and the goal is to have the = rocket touch the ground below some threshold velocity.

I thought it would be neat, after a game completes, to print a graph sh= owing the descent.

Given these measurements:
measurement_dict =3D { # time, height
=C2=A0 =C2=A0 0: 10,
=C2=A0 =C2=A0 1: 9,
=C2=A0 =C2=A0 2: 9,=
=C2=A0 =C2=A0 3: 8,<= /font>
=C2=A0 =C2=A0 = 4: 8,
=C2=A0 = =C2=A0 5: 7,
=C2=A0 =C2=A0 6: 6,=
=C2=A0 =C2=A0 7: 4,<= /font>
=C2=A0 =C2=A0 = 8: 5,
=C2=A0 = =C2=A0 9: 3,
=C2=A0 =C2=A0 10: 2,
=C2=A0 =C2=A0 11: 1= ,
=C2=A0 =C2= =A0 12: 0,
}

The easiest solution is to have the= Y axis be time and the X axis distance from the ground, and the code would= be:

for t, y in measuremen= t_dict.items():

That output is not especially intuitive,= though. =C2=A0A better visual would be an X axis of time and Y axis of dis= tance:

max_height= =3D max(measurement_dict.values())
max_time =3D max(measurement_dict.keys())
for height in range(max_height,= 0, -1):
=C2= =A0 =C2=A0 row =3D list(" " * max_time)
=C2=A0 =C2=A0 for t, y in measurement_d= ict.items():
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 if y >=3D height:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 row[t] =3D 'X'=
=C2=A0 =C2=A0= print("".join(row))

My concern is whether the ave= rage 11-year-old will be able to follow such logic. =C2=A0Is there a better= approach?

--
https://mail.python.org/mailman/listinfo/python-list



--047d7b5d2ea487fb3204ef2c588d--