By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 1,987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

Do any of you recommend Python as a first programming language?

P: n/a
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

Thank you.
Mar 22 '08 #1
Share this Question
Share on Google+
29 Replies


P: n/a
On Mar 22, 1:40 pm, jmDesktop <needin4mat...@gmail.comwrote:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

Thank you.
Yes.

You'll probably get 100 positive answers!

Check out the edu-sig mailing list for discussions on the topic. And
you may want to check out rur-ple.sourceforge.net, where "ple" stands
for "Python Learning Environment".

André
Mar 22 '08 #2

P: n/a
jmDesktop wrote:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.
Linux and Python are a nearly ideal combination for this. Be aware that
at some point, you will likely have to dig into C, the primary language
used to implement both Linux and Python.
Mar 22 '08 #3

P: n/a
jmDesktop <ne***********@gmail.comwrites:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.
I'm not from the US and I'm not sure what 9th/12th grade are, but if
you want to use programming to explore maths, er I mean math, have a
look at the sage project:

http://www.sagemath.org/

--
Arnaud
Mar 22 '08 #4

P: n/a
Larry Bates wrote:
jmDesktop wrote:
>For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

Thank you.

ABSOLUTELY. Get them started with a REAL programming language that will
teach them proper fundamentals. I wish Python would have been around 25
years ago when I taught incoming Freshmen at local University. To get
students to understand about variable references, etc.
What do you mean by "variable references," and how are they used in Python?
Mar 22 '08 #5

P: n/a
On Mar 22, 3:48 pm, Arnaud Delobelle <arno...@googlemail.comwrote:
jmDesktop <needin4mat...@gmail.comwrites:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

I'm not from the US and I'm not sure what 9th/12th grade are, but if
you want to use programming to explore maths, er I mean math, have a
look at the sage project:
9th grade roughly corresponds to 3e collège and 10th/12th grade
roughly correspond to the first three years of "le lycée" - although
from my past teaching experience (as a physicist) in French, I have
concluded that mathematics is taught at a higher level in France than
it is in North America - simply looking at the various books available
on given topics.
http://www.sagemath.org/
Sage is great. However, I think it is much too advanced for 9th/12th
grade. Furthermore, the OP was looking for suggestion teaching
*programming*, not math.

André
>
--
Arnaud
Mar 22 '08 #6

P: n/a
jmDesktop <ne***********@gmail.comwrites:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience?
It's at least pretty good. It's not ideal, but nothing ever is.

What I mean is: it's the best suggestion I can think of, but I can't
say with confidence that there's nothing better out there.
Alternatives would probably be more esoteric languages like Logo.

Chris Okasaki (of functional data structures fame) has an interesting
blog post about why indentation-based structuring is a big help for
teaching:

http://okasaki.blogspot.com/2008/02/...ation-for.html
Mar 22 '08 #7

P: n/a
On Mar 22, 3:34*pm, bsoist <soistm...@gmail.comwrote:
On Mar 22, 12:40 pm, jmDesktop <needin4mat...@gmail.comwrote:
For students 9th - 12th grade, with at least Algebra I. *Do you think
Python is a good first programming language for someone with zero
programming experience? *Using Linux and Python for first exposure to
programming languages and principles.
Thank you.

Absolutely. I love using Python in "the real world" but it is
fantastic for beginning programmers.

Python enforces good habits and presents many opportunities to discuss
programming from an academic perspective. Why does Python not have a
switch or until statement? Why are very common objects (stack, queue,
linked list) not builtin? etc.
Beginning programmers in grades 9-12 are not going to understand
issues like that, and it would be a mistake to try and introduce
them. Beginning programmers should be concentrating their efforts on
learning the syntax of a language and basic constructs like for-loops
and if statements. They will begin by writing simple "hello world"
style programs, and as their basic skills improve, the programs will
get a little more complex and require some more thought and some math
to solve the problems presented to them. String formatting should
probably be introduced to help with formatting the output. That is
about as far as things are going to go.

Terms like "Touring machines" and "lambda-calculus" are not going to
be mentioned anywhere in the course of study.
Mar 22 '08 #8

P: n/a
On Mar 22, 11:40*am, jmDesktop <needin4mat...@gmail.comwrote:
For students 9th - 12th grade, with at least Algebra I. *Do you think
Python is a good first programming language for someone with zero
programming experience? *Using Linux and Python for first exposure to
programming languages and principles.

Thank you.
I absolutely support Python as a first programming language, from 7th
grade on up. Here is a link at the main Python web site that should
give you a number of additional resources: http://www.python.org/community/sigs/current/edu-sig/

-- Paul
Mar 23 '08 #9

P: n/a
On Sat, 22 Mar 2008 21:11:51 -0700, sturlamolden wrote:
On 22 Mar, 23:42, 7stud <bbxx789_0...@yahoo.comwrote:
>Beginning programmers in grades 9-12 are not going to understand issues
like that, and it would be a mistake to try and introduce them.
Beginning programmers should be concentrating their efforts on learning
the syntax of a language and basic constructs like for-loops and if
statements.

Yes. And because Python is a "scripting language"

Python is a programming language. It can be used for scripting, but
that's not all it can do. Describing it as a "scripting language" is like
describing a fully-equipped professional kitchen as "a left-over warming
room".

--
Steven
Mar 23 '08 #10

P: n/a
Jeff Schwab <je**@schwabcenter.comwrites:
I've been learning a fair amount about functional programming
recently, mostly because compile-time C++ turns out to be a pure
functional programming language. Where should I go for a solid
grounding in lambda-calculus?
For PL theory in general, try this:

http://www.cs.cmu.edu/~rwh/plbook/book.pdf
Mar 23 '08 #11

P: n/a
On Mar 22, 11:29�pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
On Sat, 22 Mar 2008 21:11:51 -0700, sturlamolden wrote:
On 22 Mar, 23:42, 7stud <bbxx789_0...@yahoo.comwrote:
Beginning programmers in grades 9-12 are not going to understand issues
like that, and it would be a mistake to try and introduce them.
Beginning programmers should be concentrating their efforts on learning
the syntax of a language and basic constructs like for-loops and if
statements.
Yes. And because Python is a "scripting language"

Python is a programming language. It can be used for scripting, but
that's not all it can do. Describing it as a "scripting language" is like
describing a fully-equipped professional kitchen as "a left-over warming
room".
Sure, but then again, some are chefs, others merely
cooks and yet others just warm leftovers.
>
--
Steven
Mar 23 '08 #12

P: n/a
Paul Rubin wrote:
Jeff Schwab <je**@schwabcenter.comwrites:
>I've been learning a fair amount about functional programming
recently, mostly because compile-time C++ turns out to be a pure
functional programming language. Where should I go for a solid
grounding in lambda-calculus?

For PL theory in general, try this:

http://www.cs.cmu.edu/~rwh/plbook/book.pdf
What a mess. That's some professor inventing his very own variation on
predicate calculus and writing a book using his own notation and terminology.
There's no sign of footnotes or references to prior work. The notation
doesn't seem to do anything not previously possible; it's just different.

Back when I was doing program verification work, we used to refer to
stuff like that as the "logic of the month club".

John Nagle
Mar 23 '08 #13

P: n/a
John Nagle <na***@animats.comwrites:
What a mess. That's some professor inventing his very own variation on
predicate calculus and writing a book using his own notation and terminology.
I thought it was all pretty standard. It's the same notation I see in
other PL stuff.
There's no sign of footnotes or references to prior work.
Maybe he'll add that. It's a work in progress.
Back when I was doing program verification work, we used to refer to
stuff like that as the "logic of the month club".
I thought the book was pretty good and I've learned quite a bit from
the parts I've read. Also, the author is one of the big cheeses in
the SML world, if that matters.
Mar 23 '08 #14

P: n/a
On Sat, 22 Mar 2008 23:15:00 -0700, John Nagle wrote:
That's some professor inventing his very own variation on predicate
calculus and writing a book using his own notation and terminology.
There's no sign of footnotes or references to prior work. The notation
doesn't seem to do anything not previously possible; it's just
different.
You say that as if it were unusual in maths circles :)

--
Steven
Mar 23 '08 #15

P: n/a
On Mar 22, 5:40 pm, jmDesktop <needin4mat...@gmail.comwrote:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

Thank you.
Yes. The nice thing with Python is that you can start off with really
simple examples and slowly build up the complexity along with the
understanding of the students. There's no need to explain OO before
the students can write their first 'Hello, world'.

There's almost no limit to how 'shallow/deep' you can go with Python.

2B
Mar 23 '08 #16

P: n/a
On Mar 23, 8:14*am, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
On Sat, 22 Mar 2008 23:15:00 -0700, John Nagle wrote:
That's some professor inventing his very own variation on predicate
calculus and writing a book using his own notation and terminology.
There's no sign of footnotes or references to prior work. *The notation
doesn't seem to do anything not previously possible; it's just
different.

You say that as if it were unusual in maths circles :)
Haha. As opposed to programmers who have all agreed to use the same
language.

Anyway, I have browsed the book and agree with Paul Rubin that there
doesn't seem to be any unusual notation in it, although there are a
numbers of topics that I am not really familiar with.

--
Arnaud

Mar 23 '08 #17

P: n/a
On 2008-03-22, bsoist <so*******@gmail.comwrote:
On Mar 22, 12:40 pm, jmDesktop <needin4mat...@gmail.comwrote:
>For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

Thank you.

Absolutely. I love using Python in "the real world" but it is
fantastic for beginning programmers.

Python enforces good habits and presents many opportunities to discuss
programming from an academic perspective. Why does Python not have a
switch or until statement?
Why doesn't it?
Why are very common objects (stack, queue,
linked list) not builtin? etc.
I think I know this one: you just use builtin lists to do stacks, queues
and, er, lists.
Mar 23 '08 #18

P: n/a
On Mar 22, 10:40 am, jmDesktop <needin4mat...@gmail.comwrote:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.
Yes.
Thank you.
You're welcome.
Mar 23 '08 #19

P: n/a
On Sun, 23 Mar 2008 09:24:35 -0700, Aahz wrote:
The problem with lambda is that too often it results in clutter (this is
a strictly made-up example off the top of my head for illustrative
purposes rather than any real code, but I've seen plenty of code similar
at various times):

gui.create_window(origin=(123,456), background=gui.WHITE,
foreground=gui.BLACK, callback=lambda x: x*2)

That means I need to pause reading the create_window() arguments while I
figure out what the lambda means -- and often the lambda is more
complicated than that. Moreover, because the lambda is unnamed, it's
missing a reading cue for its purpose.

And of course this would be so much better:

def double(x): return x*2

gui.create_window(origin=(123,456), background=gui.WHITE,
foreground=gui.BLACK, callback=double)
Not.

The source of the "clutter" (having *less* code is clutter???) and
confusion isn't the lambda, it's the callback.

--
Steven

Mar 23 '08 #20

P: n/a
On Mar 22, 6:40 pm, Jeff Schwab <j...@schwabcenter.comwrote:
jmDesktop wrote:
For students 9th - 12th grade, with at least Algebra I. Do you think
Python is a good first programming language for someone with zero
programming experience? Using Linux and Python for first exposure to
programming languages and principles.

Linux and Python are a nearly ideal combination for this. Be aware that
at some point, you will likely have to dig into C, the primary language
used to implement both Linux and Python.
I've been using Python for five years and now work full-time as a
Python programmer. I've not had to hit C. :-)

Michael Foord
http://www.ironpythoninaction.com
Mar 23 '08 #21

P: n/a
On 23 Mrz., 09:31, Arnaud Delobelle <arno...@googlemail.comwrote:
On Mar 23, 8:14 am, Steven D'Aprano <st...@REMOVE-THIS-

cybersource.com.auwrote:
On Sat, 22 Mar 2008 23:15:00 -0700, John Nagle wrote:
That's some professor inventing his very own variation on predicate
calculus and writing a book using his own notation and terminology.
There's no sign of footnotes or references to prior work. The notation
doesn't seem to do anything not previously possible; it's just
different.
You say that as if it were unusual in maths circles :)

Haha. As opposed to programmers who have all agreed to use the same
language.

Anyway, I have browsed the book and agree with Paul Rubin that there
doesn't seem to be any unusual notation in it, although there are a
numbers of topics that I am not really familiar with.

--
Arnaud
The author at least introduces his notation in the initial chapter.
This is good style among mathematicians who introduce conventions at
the beginning of their books or in an appendix.

Note that I'm with Paul here but I'm not sure what John is complaining
about anyway. Maybe sequent calculus ( natural deduction ) which was
introduced by Gentzen around 75 years ago?

http://en.wikipedia.org/wiki/Sequent_calculus

Mar 24 '08 #22

P: n/a
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
On Sun, 23 Mar 2008 13:51:34 -0400, Roy Smith wrote:
On the other hand, when I do:

def torture():
woman.putInChair()
cushion.poke()
rack.turn()

I've also done two things. First, I've created a function object (i.e.
a lambda body), and I've also bound the name torture to that function
object, in much the same way I did with the list. But, it's different.
The function object KNOWS that it's name is torture.

No it does not. Function objects don't know their name. All they know is
that they have a label attached to them that is useful to use as a name
in some contexts, e.g. when printing tracebacks. It's just a label,
nothing more.
I think we're arguing the same thing. When you write

def foo():
whatever

you create an object which contains the string "foo", retrievable through
its __name__ attribute. That's what I meant by "it knows its name"
>What Python give us with lambdas is some half-way thing. It's not a
full function, so it's something that people use rarely,

Which people?
which means most people (like me) can't remember the exact syntax.

Speak for yourself, not for "most people".
Well, OK. When I said, "most people", I really meant "I know about me, and
I'm guessing about other people". I still think it's a fair statement that
if you look any large collection of Python code, you will find many more
uses of def than of lambda.
Even when I know
it's the right thing to be using in a situation, I tend not to use it
simply because the path of least resistance is to write a one-off
function vs. looking up the exact syntax for a lambda in the manual.

lambda arguments : expression

Why is that harder to remember than this?

def name ( arguments ) :
block
because I remember things I use often, better than I remember things I use
infrequently.
Mar 24 '08 #23

P: n/a
On Sun, 23 Mar 2008 22:36:35 -0400, Roy Smith wrote:
I've also done two things. First, I've created a function object
(i.e. a lambda body), and I've also bound the name torture to that
function object, in much the same way I did with the list. But, it's
different. The function object KNOWS that it's name is torture.

No it does not. Function objects don't know their name. All they know
is that they have a label attached to them that is useful to use as a
name in some contexts, e.g. when printing tracebacks. It's just a
label, nothing more.

I think we're arguing the same thing. When you write

def foo():
whatever

you create an object which contains the string "foo", retrievable
through its __name__ attribute. That's what I meant by "it knows its
name"

But that's not true. Firstly, you can't access the __name__ attribute
unless you already have a reference to the object (not necessarily a
name), so clearly the __name__ attribute isn't how you retrieve objects.

Secondly, the __name__ attribute has no special purpose. It's not even
used for tracebacks.

>>def foo():
.... return "result"
....
>>foo.__name__ = "something"
something()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'something' is not defined
>>>
something = foo
something()
'result'
>>something(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: foo() takes no arguments (1 given)
>>something.__name__
'something'
--
Steven
Mar 24 '08 #24

P: n/a
On Mon, 24 Mar 2008 04:33:53 -0400, Terry Reedy wrote:
The fact that .func_name (which is writeable) is not used at first
surprised me until I remembered that code objects can potentially be
used by multiple function objects and hence are not connected to any one
in particular.
How does that happen?

And if it is the case, what's the justification for giving them a co_name
attribute? Surely the name of the function should be that of the function
object, not of one of the shared parts?
--
Steven
Mar 24 '08 #25

P: n/a
On Mar 24, 1:26*pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
On Mon, 24 Mar 2008 04:33:53 -0400, Terry Reedy wrote:
The fact that .func_name (which is writeable) is not used at first
surprised me until I remembered that code objects can potentially be
used by multiple function objects and hence are not connected to any one
in particular.

How does that happen?
Like this:
>>def foomaker(x):
... def foo(y): return x+y
... return foo
...
>>foo1 = foomaker(1)
foo2 = foomaker(2)
foo1.func_code
<code object foo at 0x73530, file "<stdin>", line 2>
>>foo2.func_code
<code object foo at 0x73530, file "<stdin>", line 2>

Of course foo1 and foo2 are not the same thing:
>>foo1(8)
9
>>foo2(8)
10
And if it is the case, what's the justification for giving them a co_name
attribute? Surely the name of the function should be that of the function
object, not of one of the shared parts?
>>foo1.__name__
'foo'
>>foo1.func_code.co_name
'foo'

As seen above, func.__name__ and func.func_code.co_name are the same
thing (until tampered with).

--
Arnaud

Mar 24 '08 #26

P: n/a
On Mon, 24 Mar 2008 06:48:10 -0700, Arnaud Delobelle wrote:
On Mar 24, 1:26Â*pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
>On Mon, 24 Mar 2008 04:33:53 -0400, Terry Reedy wrote:
The fact that .func_name (which is writeable) is not used at first
surprised me until I remembered that code objects can potentially be
used by multiple function objects and hence are not connected to any
one in particular.

How does that happen?

Like this:
>>>def foomaker(x):
... def foo(y): return x+y
... return foo
...
>>>foo1 = foomaker(1)
foo2 = foomaker(2)
foo1.func_code
<code object foo at 0x73530, file "<stdin>", line 2>
>>>foo2.func_code
<code object foo at 0x73530, file "<stdin>", line 2>

Ah, that makes sense. And obvious in hindsight.

Of course foo1 and foo2 are not the same thing:
Naturally not. They are different functions. The fact that they share a
small part (func_code) is irrelevant. There's more to a function than the
code object.
>And if it is the case, what's the justification for giving them a
co_name attribute? Surely the name of the function should be that of
the function object, not of one of the shared parts?
>>>foo1.__name__
'foo'
>>>foo1.func_code.co_name
'foo'

As seen above, func.__name__ and func.func_code.co_name are the same
thing (until tampered with).
Yes, but what I'm asking is why the code objects have a co_name
attribute. And even if there's a good reason for code objects to have a
name, why do tracebacks use func.func_code.co_name instead of
func.__name__?
--
Steven
Mar 24 '08 #27

P: n/a
On Mar 24, 2:01*pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
[...]
>
Yes, but what I'm asking is why the code objects have a co_name
attribute. And even if there's a good reason for code objects to have a
name, why do tracebacks use func.func_code.co_name instead of
func.__name__?
From what I remember when I looked at the source: stack frames execute
code objects, not functions. They don't know what function has
spawned them, only what code object they are executing. In fact when
one thinks of it, it makes more sense for code objects to have a name
(taken from the def statement) than for function objects, as there is
exactly one code object for every def statement.

--
Arnaud

Mar 24 '08 #28

P: n/a

"Arnaud Delobelle" <ar*****@googlemail.comwrote in message
news:ce**********************************@c19g2000 prf.googlegroups.com...
>From what I remember when I looked at the source: stack frames execute
code objects, not functions. They don't know what function has
spawned them, only what code object they are executing. In fact when
one thinks of it, it makes more sense for code objects to have a name
(taken from the def statement) than for function objects, as there is
exactly one code object for every def statement.

This is what I tried to say before. Function objects have the attributes
needed to call the code. Code objects have attributes needed to execute
the code. Both have a name for str() and repr().

tjr

Mar 25 '08 #29

P: n/a
On Sun, Mar 23, 2008 at 4:29 AM, Steven D'Aprano
<st***@remove-this-cybersource.com.auwrote:
Python is a programming language. It can be used for scripting, but
that's not all it can do. Describing it as a "scripting language" is like
describing a fully-equipped professional kitchen as "a left-over warming
room".
+1 QOTW.

--
Cheers,
Simon B.
si***@brunningonline.net
http://www.brunningonline.net/simon/blog/
Mar 26 '08 #30

This discussion thread is closed

Replies have been disabled for this discussion.