Sum of few numbers by using for and range

Chris Angelico rosuav at gmail.com
Sun Feb 17 14:32:11 EST 2019


On Mon, Feb 18, 2019 at 6:12 AM DL Neil <PythonList at danceswithmice.info> wrote:
> > sure you truly understand what is going on. Try to piece together what
> > a section of code is doing, step by step. Write down on a piece of
> > paper what the variables are at each point in the program. Then, AFTER
> > doing the work manually, run the code and see if you were right.
>
> +1
>
> The reason this course caught my attention (and which is relevant to
> you, per Chris' and Dennis' recent advice) is that the course revolves
> around an 'active textbook'. This intersperses learning material with
> mastery exercises, and pertinently, uses a 'widget' which steps through
> code, line-by-line, showing exactly what is happening to each variable.
> I was impressed!

That sounds like an EXCELLENT way to do the second part - running the
code to see if you were right. I would still recommend doing it 100%
manually first, *writing down* your expectations, and only *then*
letting the computer do it. It's easy to watch the computer do
something and go "yes, of course that's what happens", but to still
not be able to replicate it yourself. True comprehension means being
able to predict what will happen.

Consider it like a falsifiable hypothesis in scientific research. "I
expect that, when I do X, Y, and Z, the result will be Q." Then you
actually perform those steps, and see what the result is. Were you
right? If not, how do you modify your expectations/hypothesis to
correct it? It's the last step that is the most interesting, because
that's where you truly learn. (And sometimes, that learning is
expanding the corpus of human knowledge. It's only when you disprove
your expectations that you can begin to pin down something like "oh so
time flows at different rates depending on gravity" or "huh, so it
turns out black-body radiation doesn't behave the way all the math
said it would".)

ChrisA


More information about the Python-list mailing list