~marcus@TTBP



20 february 2018

Hello, town!

It's been a while yet again. As usual, I don't post much unless something consciously reminds me that I can and probably should. Recently, a townie told me that they had gone and read my feels entries, and I thought to myself "I haven't even read my own feels entries in a while ... let's do that!"

And so, I took my time reading through my entries. It was a good exercise in self-reflection, and it reminded me that I want to put some more effort into a few of my creative ideas again. Perhaps do some more fiction writing.

Also, my oldest son, who is 9 years old now, is learning Python, with my help. He wants to lear, and so I am slowly introducing him to the language and trying to convince him that a slow pace is best for truly understanding what he is doing.

So far (using Python 2.7.x), he has a fairly good grasp of:

The topics I've introduced that I want him to get a better understanding of are:

For only a weekend of learning, I think we're making progress. The piece of code we are currently playing with as part of our learning is a quick "Guess the Number" game I wrote with him asking and answering questions beside me. The code is here (note that it is dead simple with no error handling):

import random

answer = random.randint(1,101)
guess = 0

while guess != answer:
  guess = int(raw_input("Guess a number between 1 and 100: "))
  if guess > answer:
    print str(guess) + " is too high."
  elif guess < answer:
    print str(guess) + " is too low."
  else:
    print "Correct! " + str(answer) + " is the answer!"
    playagain = raw_input("Would you like to play again? (Yes or No) ")
    if playagain == "Yes":
      answer = random.randint(1,101)
      guess = 0

The "playagain" option is something we discussed while adding it to a previous version of the code. He's been good so far about the slow pace I'm going, but he does keep wanting to jump ahead. This is fine, though; I'm happy that he wants to explore the code himself, and if I'm not free to help him he sometimes tries things out himself to see if he can figure it out on his own. I'm quite proud of him. :D

That's all for now. Take care, town! I will write again soon! (I think ...)