The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

This topic is READ ONLY
Fender Strat (10) [Avatar] Offline
#1
Hello.

I'm a forty-four year old man who is going through this book to evaluate its pedagogical effectiveness for its intended audience (eg., my nephew, age eleven). You've pretty much nailed it. I've just finished chapter fourteen, and so far, I give it 9 out of 10 stars. Great job, Mister and Master Sande!

Now, about chapter 11, "Try it out" exercise 2. While I realize that the point of the exercise is to develop a solution that employs a nested loop, one is not needed. A more efficient solution, which uses much less code, would be this:

import time

tMinus = int(raw_input("How many seconds to count down? ")) #Or some such question

for i in range(tMinus, 0, -1):
print i, i * '*' # Prints the value of "i" and then "i" times "*"
time.sleep(1)
print "BLAST OFF!"

The output looks like this:

How many seconds to count down? 10
10 **********
9 *********
8 ********
7 *******
6 ******
5 *****
4 ****
3 ***
2 **
1 *
BLAST OFF!

=================================================

The only reason that I mention this is that at the end of the exercise, you guys say: "(Hint: You probably need to use a nested loop.)" This hint, in the mind of a young reader, tends to make the youngster think that the problem can be solved only by using a nested loop. Since a nested loop isn't necessary, perhaps it would be better to say something such as this: "Although there is more than one way to skin this cat, try using a nested loop to solve this problem."

Again, I think that you guys have done a great job!
warren.sande (211) [Avatar] Offline
#2
Re: Chapter 11, Try it Out Exercise 2
Thanks for the comments and the suggestion. It's a good suggestion, and we'll look at making a change like that the next time we revise the book.

I'm hope your nephew enjoys the book, too!


Regards,
Warren Sande
Sean C. (11) [Avatar] Offline
#3
Re: Chapter 11, Try it Out Exercise 2
Yes, good suggestion.

When I go through that chapter with someone, I think I'll show both ways, and ask the question "Now, this eye times star line. What do you suppose is going on under the hood there?"

And do a socratic thing where we wind up agreeing that both an implicit nested loop (eye times star) and explicit nested loop have a lot in common.
Fender Strat (10) [Avatar] Offline
#4
Re: Chapter 11, Try it Out Exercise 2
Thank you. The suggestion accomplishes a number of good things.

First: it helps the student to enhance his programming skill set by helping him learn that there is more than one programming concept that can be used to solve this problem (eg., using a single print statement OR a nested for loop).

Second: it motivates him to review and employ many elements of the language in his search for a solution.

Third: it expands the student's horizons and understanding by motivating him to search for, and to create, different solutions to the same problem.

Lastly: items one through three above will help the student to discover the most efficient way to solve a programming problem. In this example, a single print statement in my simple solution replaces a two line for loop that repeats its print statement many times.