Req. comments on "first version" ch 2 progr. intro (using Python3.x in Windows)

Discussion in 'Python' started by Alf P. Steinbach, Nov 9, 2009.

  1. Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far.

    It's now Python 3.x, and reworked with lots of graphical examples and more
    explanatory text, plus limited in scope to Basic Concepts (which I previously
    just had as a first ch 2 section -- but there's rather a lot of concepts!).

    I think it's wise to invite comments even when it's not 100% completed. First,
    because as opposed to ch 1 there is quite a bit of code here, and since I'm a
    Python newbie I may be using non-idiomatic constructs, not to mention doing
    worse things. :) Second, because comments in general can improve the text.


    Contents:

    2.1 Super-basic concept: why programming is not DWIM. 1
    2.2 Reported errors. 4
    2.2.1 Case-sensitity. 4
    2.2.2 Syntax / compilation errors. 4
    2.2.3 Runtime errors / crashes. 5
    2.3 A programming exploration tool: turtle graphics. 6
    2.4 Naming things. 8
    2.4.1 Naming actions: routines. 8
    2.4.2 Naming data part I: variables. 11
    2.4.3 Naming data part II: routine arguments. 13
    2.5 Controlling the flow of execution. 14
    2.5.1 Repeating actions automatically: loops. 14
    2.5.2 Basic comparisions & boolean values. 16
    2.5.3 Interlude I: a function graph program / about types. 17
    2.5.4 Automated action choices. 21
    2.5.5 Value-producing (function-like) routines. 23
    2.5.6 Interlude II: a graph with zeroes marked / about program structure. 26
    2.5.7 Dynamically nested actions: recursive routines. 28
    2.6 Objects. [Not started on this] 31
    2.7 Collections. [Not started on this] 31


    In Google Docs (both chapters available here):

    <url: http://preview.tinyurl.com/ProgrammingBookP3>
    Formats: PDF


    Cheers,

    - Alf
     
    Alf P. Steinbach, Nov 9, 2009
    #1
    1. Advertising

  2. Alf P. Steinbach

    Jon Clements Guest

    On Nov 9, 4:10 pm, "Alf P. Steinbach" <> wrote:
    > Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far.
    >
    > It's now Python 3.x, and reworked with lots of graphical examples and more
    > explanatory text, plus limited in scope to Basic Concepts (which I previously
    > just had as a first ch 2 section  --  but there's rather a lot of concepts!).
    >
    > I think it's wise to invite comments even when it's not 100% completed. First,
    > because as opposed to ch 1 there is quite a bit of code here, and since I'm a
    > Python newbie I may be using non-idiomatic constructs, not to mention doing
    > worse things. :) Second, because comments in general can improve the text.
    >
    > Contents:
    >
    > 2.1 Super-basic concept: why programming is not DWIM.   1
    > 2.2 Reported errors.    4
    > 2.2.1   Case-sensitity. 4
    > 2.2.2   Syntax / compilation errors.    4
    > 2.2.3   Runtime errors / crashes.   5
    > 2.3 A programming exploration tool: turtle graphics.    6
    > 2.4 Naming things.  8
    > 2.4.1   Naming actions: routines.   8
    > 2.4.2   Naming data part I: variables.  11
    > 2.4.3   Naming data part II: routine arguments. 13
    > 2.5 Controlling the flow of execution.  14
    > 2.5.1   Repeating actions automatically: loops. 14
    > 2.5.2   Basic comparisions & boolean values.    16
    > 2.5.3   Interlude I: a function graph program / about types.    17
    > 2.5.4   Automated action choices.   21
    > 2.5.5   Value-producing (function-like) routines.   23
    > 2.5.6   Interlude II: a graph with zeroes marked / about program structure. 26
    > 2.5.7   Dynamically nested actions: recursive routines. 28
    > 2.6 Objects.     [Not started on this] 31
    > 2.7 Collections.    [Not started on this] 31
    >
    > In Google Docs (both chapters available here):
    >
    >      <url:http://preview.tinyurl.com/ProgrammingBookP3>
    >      Formats: PDF
    >
    > Cheers,
    >
    > - Alf


    Well, you may not like it, but it is perfectly acceptable and indeed
    promoted to use CONSTANT_VAR_NAMES. You're almost discouraging the use
    of a well understood and oft-used idiom. I they're a lot of them, you
    generally have a settings module, that just lists all of the
    'constants' (.h files effectively).

    "Technically line_length is a variable"...: No - it's a name that
    binds to an object that happens to be an integer. You've participated
    in discussions re: this. Similarly 'number_of_apples =
    number_of_apples + 1' is not an assignment ;) It's nit-picky and I
    realise you're trying to keep it simple, but as it's meant for new
    programmers to the Python language, then introduce them to Python's
    way of "variables", they'll thank you for it later... (or run
    screaming, or start another thread here...)

    I've never seen/heard != described as "different from"; what's wrong
    with "not equal to"? And why no mention of 'not' (should be mentioned
    with booleans surely?).

    That's as far as I've got; might get around to reading more later...

    Cool tree at the end :)

    Cheers,

    Jon
     
    Jon Clements, Nov 9, 2009
    #2
    1. Advertising

  3. * Jon Clements:
    > On Nov 9, 4:10 pm, "Alf P. Steinbach" <> wrote:
    >> Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far.
    >>
    >> It's now Python 3.x, and reworked with lots of graphical examples and more
    >> explanatory text, plus limited in scope to Basic Concepts (which I previously
    >> just had as a first ch 2 section -- but there's rather a lot of concepts!).
    >>
    >> I think it's wise to invite comments even when it's not 100% completed. First,
    >> because as opposed to ch 1 there is quite a bit of code here, and since I'm a
    >> Python newbie I may be using non-idiomatic constructs, not to mention doing
    >> worse things. :) Second, because comments in general can improve the text.
    >>
    >> Contents:
    >>
    >> 2.1 Super-basic concept: why programming is not DWIM. 1
    >> 2.2 Reported errors. 4
    >> 2.2.1 Case-sensitity. 4
    >> 2.2.2 Syntax / compilation errors. 4
    >> 2.2.3 Runtime errors / crashes. 5
    >> 2.3 A programming exploration tool: turtle graphics. 6
    >> 2.4 Naming things. 8
    >> 2.4.1 Naming actions: routines. 8
    >> 2.4.2 Naming data part I: variables. 11
    >> 2.4.3 Naming data part II: routine arguments. 13
    >> 2.5 Controlling the flow of execution. 14
    >> 2.5.1 Repeating actions automatically: loops. 14
    >> 2.5.2 Basic comparisions & boolean values. 16
    >> 2.5.3 Interlude I: a function graph program / about types. 17
    >> 2.5.4 Automated action choices. 21
    >> 2.5.5 Value-producing (function-like) routines. 23
    >> 2.5.6 Interlude II: a graph with zeroes marked / about program structure. 26
    >> 2.5.7 Dynamically nested actions: recursive routines. 28
    >> 2.6 Objects. [Not started on this] 31
    >> 2.7 Collections. [Not started on this] 31
    >>
    >> In Google Docs (both chapters available here):
    >>
    >> <url:http://preview.tinyurl.com/ProgrammingBookP3>
    >> Formats: PDF
    >>
    >> Cheers,
    >>
    >> - Alf

    >
    > Well, you may not like it, but it is perfectly acceptable and indeed
    > promoted to use CONSTANT_VAR_NAMES. You're almost discouraging the use
    > of a well understood and oft-used idiom. I they're a lot of them, you
    > generally have a settings module, that just lists all of the
    > 'constants' (.h files effectively).


    Yeah, I thought of that angle so I emphasized 'programs'.

    As it happens about half or more of the variables in the examples are constants.

    All uppercase convention for that would be ugly to me. :)



    > "Technically line_length is a variable"...: No - it's a name that
    > binds to an object that happens to be an integer. You've participated
    > in discussions re: this. Similarly 'number_of_apples =
    > number_of_apples + 1' is not an assignment ;)


    Ah, you're kidding.

    Probably.

    Anyways, that's the terminology employed by the language reference, and even if
    it wasn't I'd use it because this is primarily introduction to programming in
    general, where Python just happens to be the vehicle; thus, language independent
    terminology preferred (e.g., I use "routine" instead of C/Python "function").


    > It's nit-picky and I
    > realise you're trying to keep it simple, but as it's meant for new
    > programmers to the Python language, then introduce them to Python's
    > way of "variables", they'll thank you for it later... (or run
    > screaming, or start another thread here...)


    Yeah, good point, thanks!

    But it will have to wait till I get down into details... ;-)


    > I've never seen/heard != described as "different from"; what's wrong
    > with "not equal to"?


    Thanks!


    > And why no mention of 'not' (should be mentioned
    > with booleans surely?).


    Again, I'll discuss that later. It's just too much to bring up. Most of my work
    with this has been to pare down to essentials and *remove* stuff I'd written.


    > That's as far as I've got; might get around to reading more later...
    >
    > Cool tree at the end :)


    Thanks!

    Cheers,

    - Alf
     
    Alf P. Steinbach, Nov 9, 2009
    #3
  4. Alf P. Steinbach

    Guest

    On Nov 9, 2009, at 11:54 AM, Jon Clements wrote:

    > On Nov 9, 4:10 pm, "Alf P. Steinbach" <> wrote:
    >> First, because as opposed to ch 1 there is quite a bit of code
    >> here, and since I'm a
    >> Python newbie I may be using non-idiomatic constructs,


    Welp, there goes my last excuse.

    I'm off to write my book:

    Heart Surgery at Home

    ***************
    How to Save Thousands and
    Get Results Just Like in Hospital
    ********

    Chapter 1: Sanitation, Schmanitation: How Clean is Clean Enough?
    Chapter 2: Surgical Tools vs. Ginsu: How Sharp is Sharp Enough?
    Chapter 3: Gray's Anatomy and Sharpies: Laying out The Surgery
    Chapter 4: Before You Start: Charging Your Cell Phone, and Testing 911
    Chapter 5: Anesthesia: Jack Daniels or Smirnoffs; How Much is Enough?
    Chapter 6: The Insanity Defense: Laying the Groundwork with 6 Month Plan

    That's as far as I've gotten...

    Amazon best seller list, here I come!

    S
     
    , Nov 9, 2009
    #4
  5. * :
    >
    > On Nov 9, 2009, at 11:54 AM, Jon Clements wrote:
    >
    >> On Nov 9, 4:10 pm, "Alf P. Steinbach" <> wrote:
    >>> First, because as opposed to ch 1 there is quite a bit of code here,
    >>> and since I'm a
    >>> Python newbie I may be using non-idiomatic constructs,

    >
    > Welp, there goes my last excuse.
    >
    > I'm off to write my book:
    >
    > Heart Surgery at Home
    >
    > ***************
    > How to Save Thousands and
    > Get Results Just Like in Hospital
    > ********
    >
    > Chapter 1: Sanitation, Schmanitation: How Clean is Clean Enough?
    > Chapter 2: Surgical Tools vs. Ginsu: How Sharp is Sharp Enough?
    > Chapter 3: Gray's Anatomy and Sharpies: Laying out The Surgery
    > Chapter 4: Before You Start: Charging Your Cell Phone, and Testing 911
    > Chapter 5: Anesthesia: Jack Daniels or Smirnoffs; How Much is Enough?
    > Chapter 6: The Insanity Defense: Laying the Groundwork with 6 Month Plan
    >
    > That's as far as I've gotten...
    >
    > Amazon best seller list, here I come!
    >
    > S


    It helps if you have some experience with surgery on other parts of the body.


    Cheers & hth.,

    - Alf
     
    Alf P. Steinbach, Nov 9, 2009
    #5
  6. Alf P. Steinbach

    Jon Clements Guest

    On Nov 9, 5:22 pm, "Alf P. Steinbach" <> wrote:
    > * Jon Clements:
    >
    >
    >
    > > On Nov 9, 4:10 pm, "Alf P. Steinbach" <> wrote:
    > >> Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far.

    >
    > >> It's now Python 3.x, and reworked with lots of graphical examples and more
    > >> explanatory text, plus limited in scope to Basic Concepts (which I previously
    > >> just had as a first ch 2 section  --  but there's rather a lot of concepts!).

    >
    > >> I think it's wise to invite comments even when it's not 100% completed.. First,
    > >> because as opposed to ch 1 there is quite a bit of code here, and since I'm a
    > >> Python newbie I may be using non-idiomatic constructs, not to mention doing
    > >> worse things. :) Second, because comments in general can improve the text.

    >
    > >> Contents:

    >
    > >> 2.1 Super-basic concept: why programming is not DWIM.   1
    > >> 2.2 Reported errors.    4
    > >> 2.2.1   Case-sensitity. 4
    > >> 2.2.2   Syntax / compilation errors.    4
    > >> 2.2.3   Runtime errors / crashes.   5
    > >> 2.3 A programming exploration tool: turtle graphics.    6
    > >> 2.4 Naming things.  8
    > >> 2.4.1   Naming actions: routines.   8
    > >> 2.4.2   Naming data part I: variables.  11
    > >> 2.4.3   Naming data part II: routine arguments. 13
    > >> 2.5 Controlling the flow of execution.  14
    > >> 2.5.1   Repeating actions automatically: loops. 14
    > >> 2.5.2   Basic comparisions & boolean values.    16
    > >> 2.5.3   Interlude I: a function graph program / about types.    17
    > >> 2.5.4   Automated action choices.   21
    > >> 2.5.5   Value-producing (function-like) routines.   23
    > >> 2.5.6   Interlude II: a graph with zeroes marked / about program structure. 26
    > >> 2.5.7   Dynamically nested actions: recursive routines. 28
    > >> 2.6 Objects.     [Not started on this] 31
    > >> 2.7 Collections.    [Not started on this] 31

    >
    > >> In Google Docs (both chapters available here):

    >
    > >>      <url:http://preview.tinyurl.com/ProgrammingBookP3>
    > >>      Formats: PDF

    >
    > >> Cheers,

    >
    > >> - Alf

    >
    > > Well, you may not like it, but it is perfectly acceptable and indeed
    > > promoted to use CONSTANT_VAR_NAMES. You're almost discouraging the use
    > > of a well understood and oft-used idiom. I they're a lot of them, you
    > > generally have a settings module, that just lists all of the
    > > 'constants' (.h files effectively).

    >
    > Yeah, I thought of that angle so I emphasized 'programs'.
    >
    > As it happens about half or more of the variables in the examples are constants.
    >
    > All uppercase convention for that would be ugly to me. :)


    Okies, maybe introducing the fact that lots of 'programs' often have
    constants, which are quite often settings or whatever and they would
    use the uppercase notation (and if numerous, in a separate module).
    Also maybe you can introduce the fundamental idea of a 'namespace',
    maybe something like:

    class const:
    pi = 3.14
    name = 'Alf'
    language = 'Python'

    or whatever, then reference const.<var> ?

    I'm not 100% sure I'm keen on this idea, but it's an option you can
    consider at least. Introduces a couple of bits that may be discussed
    later, but I'd be a little scared that people would start thinking
    'const.' was something magical.

    >
    > > "Technically line_length is a variable"...: No - it's a name that
    > > binds to an object that happens to be an integer. You've participated
    > > in discussions re: this. Similarly 'number_of_apples =
    > > number_of_apples + 1' is not an assignment ;)

    >
    > Ah, you're kidding.
    >
    > Probably.
    >
    > Anyways, that's the terminology employed by the language reference, and even if
    > it wasn't I'd use it because this is primarily introduction to programming in
    > general, where Python just happens to be the vehicle; thus, language independent
    > terminology preferred (e.g., I use "routine" instead of C/Python "function").
    >
    > > It's nit-picky and I
    > > realise you're trying to keep it simple, but as it's meant for new
    > > programmers to the Python language, then introduce them to Python's
    > > way of "variables", they'll thank you for it later... (or run
    > > screaming, or start another thread here...)

    >
    > Yeah, good point, thanks!
    >
    > But it will have to wait till I get down into details... ;-)
    >


    Fair enough. It would be nice though to cover stuff like:

    a = [1,2,3]
    b = a

    - b is not a *copy* of a
    - b is not a *reference* to a
    - b just happens to be another name for the list object.

    And stuff about mutable/immutable: it would certainly help with a lot
    of gotcha's.

    > > I've never seen/heard != described as "different from"; what's wrong
    > > with "not equal to"?

    >
    > Thanks!
    >
    > > And why no mention of 'not' (should be mentioned
    > > with booleans surely?).

    >
    > Again, I'll discuss that later. It's just too much to bring up. Most of my work
    > with this has been to pare down to essentials and *remove* stuff I'd written.
    >


    Well, should you re-write != as "not equal to", it wouldn't hurt to
    mention a little later that not False is True and vice versa...

    > > That's as far as I've got; might get around to reading more later...

    >
    > > Cool tree at the end :)

    >
    > Thanks!
    >
    > Cheers,
    >
    > - Alf


    Cheers,

    Jon.
     
    Jon Clements, Nov 9, 2009
    #6
  7. Alf P. Steinbach

    Jon Clements Guest

    [posts snipped]

    The only other thing is that line_length is used as a constant in one
    of the programs. However, it's being mutated in the while loop
    example. It may still be in the reader's mind that line_length == 10.
    (Or maybe not)

    Cheers,

    Jon.
     
    Jon Clements, Nov 9, 2009
    #7
  8. * Alf P. Steinbach:
    > Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far.
    >
    > It's now Python 3.x, and reworked with lots of graphical examples and
    > more explanatory text, plus limited in scope to Basic Concepts (which I
    > previously just had as a first ch 2 section -- but there's rather a
    > lot of concepts!).
    >
    > I think it's wise to invite comments even when it's not 100% completed.
    > First, because as opposed to ch 1 there is quite a bit of code here, and
    > since I'm a Python newbie I may be using non-idiomatic constructs, not
    > to mention doing worse things. :) Second, because comments in general
    > can improve the text.
    >
    >
    > Contents:
    >
    > 2.1 Super-basic concept: why programming is not DWIM. 1
    > 2.2 Reported errors. 4
    > 2.2.1 Case-sensitity. 4
    > 2.2.2 Syntax / compilation errors. 4
    > 2.2.3 Runtime errors / crashes. 5
    > 2.3 A programming exploration tool: turtle graphics. 6
    > 2.4 Naming things. 8
    > 2.4.1 Naming actions: routines. 8
    > 2.4.2 Naming data part I: variables. 11
    > 2.4.3 Naming data part II: routine arguments. 13
    > 2.5 Controlling the flow of execution. 14
    > 2.5.1 Repeating actions automatically: loops. 14
    > 2.5.2 Basic comparisions & boolean values. 16
    > 2.5.3 Interlude I: a function graph program / about types. 17
    > 2.5.4 Automated action choices. 21
    > 2.5.5 Value-producing (function-like) routines. 23
    > 2.5.6 Interlude II: a graph with zeroes marked / about program
    > structure. 26
    > 2.5.7 Dynamically nested actions: recursive routines. 28
    > 2.6 Objects. [Not started on this] 31
    > 2.7 Collections. [Not started on this] 31
    >
    >
    > In Google Docs (both chapters available here):
    >
    > <url: http://preview.tinyurl.com/ProgrammingBookP3>
    > Formats: PDF


    Added discussion and examples of C curve and dragon curve to section 2.5.7 on
    recursive routines.

    Enjoy.

    :)

    I'm especially interested in comments from novices/newbies.

    E.g., is something unclear or hard to understand, or is it all as clear as
    military pea soup?


    Cheers,

    - Alf
     
    Alf P. Steinbach, Nov 11, 2009
    #8
  9. Alf P. Steinbach

    Aahz Guest

    In article <>,
    <> wrote:
    >On Nov 9, 2009, at 11:54 AM, Jon Clements wrote:
    >> On Nov 9, 4:10 pm, "Alf P. Steinbach" <> wrote:
    >>> First, because as opposed to ch 1 there is quite a bit of code
    >>> here, and since I'm a
    >>> Python newbie I may be using non-idiomatic constructs,

    >
    >Welp, there goes my last excuse.
    >
    >I'm off to write my book:
    >
    >Heart Surgery at Home
    >
    > ***************
    >How to Save Thousands and
    >Get Results Just Like in Hospital
    > ********
    >
    >Chapter 1: Sanitation, Schmanitation: How Clean is Clean Enough?
    >Chapter 2: Surgical Tools vs. Ginsu: How Sharp is Sharp Enough?
    >Chapter 3: Gray's Anatomy and Sharpies: Laying out The Surgery
    >Chapter 4: Before You Start: Charging Your Cell Phone, and Testing 911
    >Chapter 5: Anesthesia: Jack Daniels or Smirnoffs; How Much is Enough?
    >Chapter 6: The Insanity Defense: Laying the Groundwork with 6 Month Plan
    >
    >That's as far as I've gotten...
    >
    >Amazon best seller list, here I come!


    +1 QOTW
    --
    Aahz () <*> http://www.pythoncraft.com/

    [on old computer technologies and programmers] "Fancy tail fins on a
    brand new '59 Cadillac didn't mean throwing out a whole generation of
    mechanics who started with model As." --Andrew Dalke
     
    Aahz, Nov 15, 2009
    #9
    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. Joshua
    Replies:
    8
    Views:
    6,057
    Joshua
    Sep 29, 2004
  2. Alf P. Steinbach
    Replies:
    13
    Views:
    677
    Alf P. Steinbach
    Feb 1, 2005
  3. Alf P. Steinbach
    Replies:
    1
    Views:
    304
    Alf P. Steinbach
    Nov 1, 2009
  4. Alf P. Steinbach
    Replies:
    1
    Views:
    328
    Alf P. Steinbach
    Nov 30, 2009
  5. Andrew Berg
    Replies:
    0
    Views:
    339
    Andrew Berg
    Jun 16, 2012
Loading...

Share This Page