Re: Experiences/guidance on teaching Python as a first programminglanguage

Discussion in 'Python' started by bob gailer, Dec 11, 2013.

  1. bob gailer

    bob gailer Guest

    On 12/11/2013 3:43 AM, Chris Angelico wrote:
    > When you tell a story, it's important to engage the reader from the
    > start...explain "This is how to print Hello World to the
    > console" and worry about what exactly the console is (and how
    > redirection affects it)

    Highly agree. I was once given FORTRAN course materials and an
    assignment to teach this course. The first morning was spent on how to
    construct expressions! No context as to what a program was or what it
    might do or how to run it.

    As soon as that class was over I rewrote the materials so the first
    morning was how to write and run(batch job submission) a program that
    read a record, did a simple calculation and wrote the results.

    I certainly felt better about teaching this way.

    Asides:

    One student (PhD in Physics) looked at X = X + 1 and said "no it doesn't".

    Another wrote his first program. I took one look at it and saw the
    mistakes. I explained how to walk thru the program step by step. He
    exclaimed "In that much detail?".
    bob gailer, Dec 11, 2013
    #1
    1. Advertising

  2. bob gailer

    rusi Guest

    Re: Experiences/guidance on teaching Python as a first programming language

    On Wednesday, December 11, 2013 9:31:42 PM UTC+5:30, bob gailer wrote:
    > On 12/11/2013 3:43 AM, Chris Angelico wrote:
    > > When you tell a story, it's important to engage the reader from the
    > > start...explain "This is how to print Hello World to the
    > > console" and worry about what exactly the console is (and how
    > > redirection affects it)

    > Highly agree. I was once given FORTRAN course materials and an
    > assignment to teach this course. The first morning was spent on how to
    > construct expressions! No context as to what a program was or what it
    > might do or how to run it.


    > As soon as that class was over I rewrote the materials so the first
    > morning was how to write and run(batch job submission) a program that
    > read a record, did a simple calculation and wrote the results.


    Kernighan and Ritchie set an important "first" in our field by making
    "Hello World" their first program.

    People tend to under-estimate the importance of this:
    Many assumptions need to be verified/truthified/dovetailed
    starting from switching on the machine onwards for this to work.

    And its quite a pleasurable sense of achievement when it finally holds
    together -- something which is sorely missing in the Dijkstra approach.

    However when we have an REPL language like python, one has the choice
    of teaching the hello-world program as:

    print ("Hello World")

    or just

    "Hello World"

    The second needs one more assumption than the first, viz that we are in the
    REPL, however on the whole it creates better habits in the kids.

    [BTW: From the theoretical POV, imperative programming is 'unclean' because
    of assignment statements. From the practical POV of a teacher, the
    imperativeness of print is a bigger nuisance in students' thinking patterns
    ]

    > I certainly felt better about teaching this way.


    > Asides:


    > One student (PhD in Physics) looked at X = X + 1 and said "no it doesn't".


    Yes thats one issue in most modern imperative languages that the older generation
    (Pascal-family) did not have, viz that assignment looks like equality.

    > Another wrote his first program. I took one look at it and saw the
    > mistakes. I explained how to walk thru the program step by step. He
    > exclaimed "In that much detail?".
    rusi, Dec 11, 2013
    #2
    1. Advertising

  3. On Wed, 11 Dec 2013 08:27:23 -0800, rusi wrote:

    > [BTW: From the theoretical POV, imperative programming is 'unclean'
    > because of assignment statements. From the practical POV of a teacher,
    > the imperativeness of print is a bigger nuisance in students' thinking
    > patterns ]


    +1 on this

    Trying to teach newbies to use return rather than print in their
    functions is one of the more difficult parts of teaching beginners.


    --
    Steven
    Steven D'Aprano, Dec 11, 2013
    #3
  4. On Thu, Dec 12, 2013 at 3:27 AM, rusi <> wrote:
    > However when we have an REPL language like python, one has the choice
    > of teaching the hello-world program as:
    >
    > print ("Hello World")
    >
    > or just
    >
    > "Hello World"
    >
    > The second needs one more assumption than the first, viz that we are in the
    > REPL, however on the whole it creates better habits in the kids.


    How is the bare string creating better habits? The only time I've ever
    been happy with bare strings having functionality[1] is in shell-like
    languages (including REXX; the one time I built a REXX system in which
    bare strings weren't executed as commands was a MUD, where command
    handlers could use bare strings to send lines of text to the client,
    and I wasn't happy with that - an explicit function would have been
    better). I'd much rather teach a function that produces clean output
    than depend on the REPL for Hello World. Now, depending on the REPL
    for *expressions* is quite another thing.

    >>> 1+2

    3

    That makes perfect sense! But it's using Python as a calculator, not
    as a programming language. Python blurs the line a bit, but for
    teaching programming, I'd use programming style even at the REPL:

    >>> print("Hello, world!")

    Hello, world!

    ChrisA

    [1] I don't have anything to footnote here, I just felt like having one.
    Chris Angelico, Dec 11, 2013
    #4
  5. bob gailer

    Roy Smith Guest

    Re: Experiences/guidance on teaching Python as a first programming language

    In article <>,
    rusi <> wrote:

    > Kernighan and Ritchie set an important "first" in our field by making
    > "Hello World" their first program.


    Yup.

    > People tend to under-estimate the importance of this:
    > Many assumptions need to be verified/truthified/dovetailed
    > starting from switching on the machine onwards for this to work.


    At the time that they wrote it, very few people who used computers ever
    got anywhere near the power switch :) But, the point is valid. To get
    "Hello, world" to print, you've got to figure out a lot of stuff.
    Predating the whole agile movement by two decades, it is the
    quintessential MVP. It compiles and runs. The rest is just adding
    features and fixing bugs.
    Roy Smith, Dec 12, 2013
    #5
  6. On Wed, Dec 11, 2013 at 8:42 PM, Roy Smith <> wrote:
    > In article <>,
    > rusi <> wrote:
    >
    >> Kernighan and Ritchie set an important "first" in our field by making
    >> "Hello World" their first program.

    >
    > Yup.
    >
    >> People tend to under-estimate the importance of this:
    >> Many assumptions need to be verified/truthified/dovetailed
    >> starting from switching on the machine onwards for this to work.

    >
    > At the time that they wrote it, very few people who used computers ever
    > got anywhere near the power switch :)


    Nope. Long before that I was working on computers that didn't boot
    when you powered them up, You had to manually key in a bootstrap
    program from the front panel switches. (And no, this is not a takeoff
    of the Four Yorkshiremen sketch.)
    Larry Martell, Dec 12, 2013
    #6
  7. bob gailer

    Roy Smith Guest

    Re: Experiences/guidance on teaching Python as a first programming language

    In article <>,
    Larry Martell <> wrote:

    > On Wed, Dec 11, 2013 at 8:42 PM, Roy Smith <> wrote:
    > > In article <>,
    > > rusi <> wrote:
    > >
    > >> Kernighan and Ritchie set an important "first" in our field by making
    > >> "Hello World" their first program.

    > >
    > > Yup.
    > >
    > >> People tend to under-estimate the importance of this:
    > >> Many assumptions need to be verified/truthified/dovetailed
    > >> starting from switching on the machine onwards for this to work.

    > >
    > > At the time that they wrote it, very few people who used computers ever
    > > got anywhere near the power switch :)

    >
    > Nope. Long before that I was working on computers that didn't boot
    > when you powered them up, You had to manually key in a bootstrap
    > program from the front panel switches.


    Or put a boot card in the reader and hit the IPL button :)
    Roy Smith, Dec 12, 2013
    #7
  8. Re: The increasing disempowerment of the computer user

    On 12/12/2013 02:21, Ben Finney wrote:

    > Only, now we get worldwide unaccountable surveillance as part of the deal.
    >


    Whereas the 1920 UK Official Secrets Act required all international
    cable companies operating on British terrority to submit copies of all
    their traffic (both dispatched and received) within ten days of
    transmission. Now there's accountability for you.

    --
    My fellow Pythonistas, ask not what our language can do for you, ask
    what you can do for our language.

    Mark Lawrence
    Mark Lawrence, Dec 12, 2013
    #8
  9. bob gailer

    rusi Guest

    Re: Experiences/guidance on teaching Python as a first programming language

    On Thursday, December 12, 2013 7:12:32 AM UTC+5:30, Roy Smith wrote:
    > rusi wrote:


    > > Kernighan and Ritchie set an important "first" in our field by making
    > > "Hello World" their first program.


    > Yup.


    > > People tend to under-estimate the importance of this:
    > > Many assumptions need to be verified/truthified/dovetailed
    > > starting from switching on the machine onwards for this to work.


    > At the time that they wrote it, very few people who used computers ever
    > got anywhere near the power switch :) But, the point is valid. To get
    > "Hello, world" to print, you've got to figure out a lot of stuff.
    > Predating the whole agile movement by two decades, it is the
    > quintessential MVP. It compiles and runs. The rest is just adding
    > features and fixing bugs.


    Which comes back full-circle to where we started: if

    main() { printf("Hello World\n"); }

    is the foundation on which other programs are built, then later excising
    the print(f) is a significant headache -- at least for teachers as Steven
    also seems to have found.

    If instead the print was presented more as a 'debug' -- when something
    goes wrong stick a probe in there and figure the problem -- then
    leaving it there would be as unacceptable as a car mechanic giving you
    your keys with the hood open and parts lying around.

    Anecdote about the great mathematician Gauss: He was asked why
    his writings were so devoid of motivations/explanations. He answered:
    Do you leave the scaffolding after the building is built?
    rusi, Dec 12, 2013
    #9
  10. On Thu, Dec 12, 2013 at 2:52 PM, rusi <> wrote:
    > Which comes back full-circle to where we started: if
    >
    > main() { printf("Hello World\n"); }
    >
    > is the foundation on which other programs are built, then later excising
    > the print(f) is a significant headache -- at least for teachers as Steven
    > also seems to have found.
    >
    > If instead the print was presented more as a 'debug' -- when something
    > goes wrong stick a probe in there and figure the problem -- then
    > leaving it there would be as unacceptable as a car mechanic giving you
    > your keys with the hood open and parts lying around.


    Console output isn't just a debug feature, though - and if you're
    using it as such, you possibly should be using the logging module
    instead. It's the most fundamental form of output. It plays nicely
    with shell redirection and long pipelines, which means it
    automatically lets you work with something larger than memory or even
    disk. Imagine starting a pipeline with a decompression step (eg gzip
    -d), and ending it with a tight filter (eg grep) - everything in
    between could manipulate any amount of data at all, without caring
    about storage space. Console output works in the REPL, works in the
    default interpreter (other than pythonw.exe which suppresses it),
    works across SSH... if your most normal form of output is a GUI,
    that's not always true. Console output works without requiring any
    other program, too, unlike (for instance) a CGI script, which needs a
    web browser to interpret its output. There's a reason many languages
    bless it with a keyword.

    ChrisA
    Chris Angelico, Dec 12, 2013
    #10
  11. Re: The increasing disempowerment of the computer user

    On Thu, 12 Dec 2013 13:35:37 +1100, Ben Finney wrote:

    > Hmm, interesting Freudian slip there. I meant “cloud computingâ€, of
    > course. That's where the computer owner pretends their service is always
    > available and easy to access, while having terms of service that give
    > them unilateral power to kick you off with no warning, no explanation,
    > no accountability, and no recourse.


    Now Ben, you know that's not true. Everybody has the only recourse that
    matters: buy the company and make them do what you want them to do. How
    hard could that possibly be?



    --
    Steven
    Steven D'Aprano, Dec 12, 2013
    #11
  12. bob gailer

    bob gailer Guest

    On 12/11/2013 9:07 PM, Larry Martell wrote:

    > Nope. Long before that I was working on computers that didn't boot
    > when you powered them up, You had to manually key in a bootstrap
    > program from the front panel switches.

    PDP8? RIM loader, BIN loader?
    bob gailer, Dec 12, 2013
    #12
  13. On Thu, Dec 12, 2013 at 11:51 AM, bob gailer <> wrote:
    > On 12/11/2013 9:07 PM, Larry Martell wrote:
    >
    >> Nope. Long before that I was working on computers that didn't boot when
    >> you powered them up, You had to manually key in a bootstrap program from the
    >> front panel switches.

    >
    > PDP8? RIM loader, BIN loader?


    Data General Nova 3
    Larry Martell, Dec 12, 2013
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oscar Benjamin
    Replies:
    110
    Views:
    642
    David Combs
    Jan 29, 2014
  2. Gene Heskett
    Replies:
    0
    Views:
    84
    Gene Heskett
    Dec 9, 2013
  3. Chris Angelico
    Replies:
    2
    Views:
    67
    Chris Angelico
    Dec 9, 2013
  4. Gene Heskett
    Replies:
    0
    Views:
    79
    Gene Heskett
    Dec 9, 2013
  5. Terry Reedy
    Replies:
    1
    Views:
    82
    Conor Hughes
    Dec 9, 2013
Loading...

Share This Page