[Edu-sig] python for kids...

Laura Creighton lac at openend.se
Sun Nov 11 01:23:06 CET 2007


read http://mail.python.org/pipermail/python-list/2002-April/140258.html

ore read the whole thread.

Then write something like Alex did.

Laura

In a message of Sun, 11 Nov 2007 11:46:54 +1300, Jason R Briggs writes:
>This is a multi-part message in MIME format.
>--===============0995048152==
>Content-Type: multipart/alternative;
>	boundary="------------080808090007040401080704"
>
>This is a multi-part message in MIME format.
>--------------080808090007040401080704
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>Content-Transfer-Encoding: 7bit
>
>Hi All
>
>I'm seeking some advice, about a change I'm thinking about making to 
>Chapter 2 of my book.  I've received a bit of criticism lately about my 
>decision to stick with the simple concept of a variable as a "box to put 
>things in", rather than explaining the difference in Python (that a 
>variable is a really a name or label for an object).
>My original thinking was to keep it simple (not go into a discussion of 
>store-by-value versus store-by-reference), but I've gradually been 
>convinced, by weight of opinion, that this wasn't the right decision.  
>When you get an email from the Associate Professor of Computer Science 
>at a Brazilian university, you tend to listen more than when you get a 
>mail from someone saying, "dude, you're an idiot, don't you know how 
>Python works!".  ;-)
>
>Anyway, I'm thinking to keep the original discussion about a variable 
>being a mailbox, and then talk about the Python distinction (see updated 
>version below), but I'm not sure that this won't just unnecessarily 
>confuse the reader.  I can scrap the mailbox stuff, but then I lose an 
>illustration (something I'm loathe to do anyway), plus I think in some 
>ways that it's useful information.
>
>Any other opinions on the matter?
>
>Thanks,
>Jason
>
>--- excerpt ---
>
>A "variable" is a programming term used to describe a place to store 
>things. The "things" can be numbers, or text, or lists of numbers and 
>text -- and all sorts of other items too numerous to go into here. For 
>the moment, let's just think of a variable as something a bit like a 
>mailbox.
>
>You can put things (such as a letter or a package) in a mailbox, just as 
>you can put things (numbers, text, lists of numbers and text, etc, etc, 
>etc) in a variable. This mailbox idea is the way many programming 
>languages work.
>
>In Python, variables are slightly different. Rather than being a box 
>with things in it, a variable is more like a label which is stuck on the 
>things. We can pull that label off and stick it on something else, or 
>even stick the label on more than one thing.
>
>We create a variable by giving it a name, using an equals sign (=), then 
>telling Python what we want that name to point at. For example:
>
> >>> fred = 100
>
>We've just created a variable called "fred" and said that it points to 
>the number 100. It's a bit like telling Python to remember that number 
>because we want to use it later. To find out what a variable is pointing 
>at, we can just type "print" in the console, followed by the variable 
>name, and hit the Enter key. For example:
>
> >>> print fred
>100
>
>We can also tell Python we want the variable fred to point at something 
>else:
>
> >>> fred = 200
> >>> print fred
>200
>
>On the first line we say we now want to fred to point at the number 200. 
>Then in the second line we ask what fred is pointing, at just to prove 
>it changed.
>
>We can also point more than one variable at the same thing:
>
> >>> john = fred
> >>> print john
>200
>
>In the code above, we're saying that we want john to point at the same 
>thing fred is pointing to.
>
>Of course, "fred" isn't a very useful name for a variable. It doesn't 
>tell us anything about what it's used for. A mailbox is easy -- you use 
>a mailbox for mail. But a variable can have a number of different uses, 
>and can point at a whole bunch of different things, so we usually want 
>something more informative to describe it.
>
>
>
>--------------080808090007040401080704
>Content-Type: text/html; charset=ISO-8859-1
>Content-Transfer-Encoding: 7bit
>
><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
><html>
><head>
>  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
></head>
><body bgcolor="#ffffff" text="#000000">
>Hi All<br>
><br>
>I'm seeking some advice, about a change I'm thinking about making to
>Chapter 2 of my book.&nbsp; I've received a bit of criticism lately about
> my
>decision to stick with the simple concept of a variable as a "box to
>put things in", rather than explaining the difference in Python (that a
>variable is a really a name or label for an object).<br>
>My original thinking was to keep it simple (not go into a discussion of
>store-by-value versus store-by-reference), but I've gradually been
>convinced, by weight of opinion, that this wasn't the right decision.&nbs
>p;
>When you get an email from the Associate Professor of Computer Science
>at a Brazilian university, you tend to listen more than when you get a
>mail from someone saying, "dude, you're an idiot, don't you know how
>Python works!".&nbsp; <span class="moz-smiley-s3"><span> ;-) </span></spa
>n><br>
><br>
>Anyway, I'm thinking to keep the original discussion about a variable
>being a mailbox, and then talk about the Python distinction (see
>updated version below), but I'm not sure that this won't just
>unnecessarily confuse the reader.&nbsp; I can scrap the mailbox stuff, bu
>t
>then I lose an illustration (something I'm loathe to do anyway), plus I
>think in some ways that it's useful information.<br>
><br>
>Any other opinions on the matter?<br>
><br>
>Thanks,<br>
>Jason<br>
><br>
>--- excerpt ---<br>
><br>
><meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
><title></title>
><meta name="GENERATOR" content="OpenOffice.org 2.3  (Linux)">
><style type="text/css">
>	<!--
>		@page { size: 21cm 29.7cm; margin: 2cm }
>		P { margin-bottom: 0.21cm; background: transparent; text-a
>lign: justify }
>		P.western { font-family: "Times New Roman", serif; font-si
>ze: 10pt }
>	-->
>	</style>
><p class="western">A &#8220;variable&#8221; is a programming term used to
>describe a place to store things. The &#8220;things&#8221; can be numbers
>,
>or text, or lists of numbers and text &#8211; and all sorts of other
>items too numerous to go into here. For the moment, let's just think
>of a variable as something a bit like a mailbox.</p>
><p class="western" style="" align="center"></p>
><p class="western" style="font-style: normal;">You
>can put things (such as a letter or a package) in a mailbox, just as
>you can put things (numbers, text, lists of numbers and text, etc,
>etc, etc) in a variable. This mailbox idea is the way many
>programming languages work.</p>
><p class="western" style="font-style: normal;">In
>Python, variables are slightly different. Rather than being a box
>with things in it, a variable is more like a label which is stuck on
>the things. We can pull that label off and stick it on something
>else, or even stick the label on more than one thing.</p>
><p class="western" style="font-style: normal;">We
>create a variable by giving it a name, using an equals sign (=), then
>telling Python what we want that name to point at. For example:</p>
><p
> style="border: medium none ; padding: 0cm; margin-left: 1cm; margin-top:
> 0.5cm; margin-bottom: 0.5cm; page-break-inside: avoid; orphans: 0; page-
>break-before: auto;"
> align="left">
><font color="#008000"><font face="Bitstream Vera Sans Mono, sans-serif"><
>font
> style="font-size: 8pt;" size="1">&gt;&gt;&gt;
>fred = 100</font></font></font></p>
><p class="western" style="font-style: normal;">We've
>just created a variable called &#8220;fred&#8221; and said that it points
> to
>the number 100. It's a bit like telling Python to remember that
>number because we want to use it later. To find out what a variable
>is pointing at, we can just type &#8220;print&#8221; in the console, foll
>owed
>by the variable name, and hit the Enter key. For example:</p>
><p
> style="border: medium none ; padding: 0cm; margin-left: 1cm; margin-top:
> 0.5cm; margin-bottom: 0.5cm; page-break-inside: avoid; orphans: 0; page-
>break-before: auto;"
> align="left">
><font color="#008000"><font face="Bitstream Vera Sans Mono, sans-serif"><
>font
> style="font-size: 8pt;" size="1">&gt;&gt;&gt;
>print fred<br>
>100</font></font></font></p>
><p class="western" style="font-style: normal;">We
>can also tell Python we want the variable fred to point at something
>else:</p>
><p
> style="border: medium none ; padding: 0cm; margin-left: 1cm; margin-top:
> 0.5cm; margin-bottom: 0.5cm; page-break-inside: avoid; orphans: 0; page-
>break-before: auto;"
> align="left">
><font color="#008000"><font face="Bitstream Vera Sans Mono, sans-serif"><
>font
> style="font-size: 8pt;" size="1">&gt;&gt;&gt;
>fred = 200<br>
>&gt;&gt;&gt; print fred<br>
>200</font></font></font></p>
><p class="western" style="font-style: normal;">On
>the first line we say we now want to fred to point at the number 200.
>Then in the second line we ask what fred is pointing, at just to
>prove it changed.
><title></title>
><meta name="GENERATOR" content="OpenOffice.org 2.3  (Linux)">
><style type="text/css">
>	<!--
>		@page { size: 21cm 29.7cm; margin: 2cm }
>		P { margin-bottom: 0.21cm; background: transparent; text-a
>lign: justify }
>		P.western { font-family: "Times New Roman", serif; font-si
>ze: 10pt }
>	-->
>	</style>
><p class="western" style="font-style: normal;">We
>can also point more than one variable at the same thing:</p>
><p
> style="border: medium none ; padding: 0cm; margin-left: 1cm; margin-top:
> 0.5cm; margin-bottom: 0.5cm; page-break-inside: avoid; orphans: 0; page-
>break-before: auto;"
> align="left">
><font color="#008000"><font face="Bitstream Vera Sans Mono, sans-serif"><
>font
> style="font-size: 8pt;" size="1">&gt;&gt;&gt;
>john = fred<br>
>&gt;&gt;&gt; print john<br>
>200</font></font></font></p>
><p class="western">In the code above, we're saying that we want
>john to point at the same thing fred is pointing to.</p>
></p>
><p class="western" style="font-style: normal;">Of
>course, &#8220;fred&#8221; isn't a very useful name for a variable. It
>doesn't tell us anything about what it's used for. A mailbox is easy
>&#8211; you use a mailbox for mail. But a variable can have a number of
>different uses, and can point at a whole bunch of different things,
>so we usually want something more informative to describe it.</p>
><br>
></body>
></html>
>
>--------------080808090007040401080704--
>
>--===============0995048152==
>Content-Type: text/plain; charset="us-ascii"
>MIME-Version: 1.0
>Content-Transfer-Encoding: 7bit
>Content-Disposition: inline
>
>_______________________________________________
>Edu-sig mailing list
>Edu-sig at python.org
>http://mail.python.org/mailman/listinfo/edu-sig
>
>--===============0995048152==--


More information about the Edu-sig mailing list