PfK and Python 2

10 Jul, 2016

Tara P writes:

I am going to be teaching Python 2 this coming school year and I am looking for a supplemental learning tool and projects for myself and my students. Will your book Python for Kids work with Python 2?

I saw that it is recommended to use Python 3 however the curriculum I am teaching we are to use Python 2.
I am not familiar enough with Python to know if the code language is different enough between them where your book will not be useful for me?

The short answer is no, it is not really designed to work with Python 2. The longer answer is that most of the code samples will work, but there are subtle differences between the two versions that may make it a little more difficult to get things working properly. There are some obvious differences (such as the tkinter module being called Tkinter in Python 2), which are straightforward to deal with and explain, but the more complicated the code, the more likely you are to hit issues that are less obvious, and as a consequence, cause frustrating errors for your students (I'm thinking more of the games in the later chapters, which aren't tested with Python2, and may either fail or hang).

While moving from Python 2 to 3 is not enormously difficult, it's not necessarily something I would recommend for learners coming to a programming language for the first time.


Python3.5 on macOS

10 Jun, 2016

If you're installing Python3.5 on macOS, you don't need to follow the Automator instructions in Python for Kids any more. After installation, it's as simple as searching for IDLE in Spotlight (the magnifying glass in the top righthand side of the menu bar) and double-clicking on (usually) the top hit ("IDLE - Python 3.5").

You might still get an error message saying something like:

The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk for current information

Tcl is a simple programming language and Tk is (sort of) a graphics library (more info here http://tldp.org/HOWTO/TclTk-HOWTO-3.html) -- the Tk graphics library is heavily used in later chapters of the book. If you happen to get the above error message, follow the instructions on the python.org website to install the correct version of ActiveTcl for the version of macOS you're running. This post may also be of help.


Python on Chromebook

01 Mar, 2016

Cynthia B writes:

I purchased your book Python for Kids so that my 11 year old daughter and I could start to learn code together. We are trying to install Python on her (lenovo 100S) chromebook to no avail.

We followed several prompts and purchased a python shell which has been installed but can not figure out where to go from here, or if this will even be possible. Any advice?

As far as I'm aware, the Python shell extensions available in the Chrome OS store aren't Python 3 compatible - so at least from a version perspective, that's a non-starter. Even if the version was correct, I suspect your mileage would probably vary with some of the later code examples in the book, using that sort of environment (not a fully fledged installation... again AFAIA).

I don't have a Chromebook to try it out myself, but from a bit of searching, it looks like you can dual-boot Linux, and after that should be able to install anything you like (http://stackoverflow.com/a/15261253/2685350 - although Samsung-specific, I would hope the basic idea still applies).

I've found some instructions on doing so at the following sites:
http://www.howtogeek.com/162120/how-to-install-ubuntu-linux-on-your-chromebook-with-crouton/
http://lifehacker.com/how-to-install-linux-on-a-chromebook-and-unlock-its-ful-509039343
http://www.linux.com/learn/tutorials/764181-how-to-install-linux-on-an-acer-c720-chromebook


Pendrive

21 Feb, 2016

Kishore writes:

I bought this great book "python for kids". I want to give it as a gift to kid in India. She doesn't have internet, but has a computer. What do I need to download and give in a pendrive, so that she can finish the book without an internet connection.

Apart from the book itself, there's two extras to download: 1 - the solutions to all the programming challenges at the end of each chapter, and 2 - the code samples in the book (in case she has difficulty getting something to work).

The solutions are available from the publishers website here: http://nostarch.com/pythonforkids. A zip file of all the code can be found here: /python-for-kids/code.zip.

Depending on when you purchased the book, you might also want to take a copy of the eratta. If it's a fairly recent reprint, there's no need. If the printing is before April 2015, then you should probably send that to her as well.

You didn't mention whether she already has Python installed, so if not, I suggest reading the first chapter yourself, so that you can include the right installation files for her OS.


A parameter called evt

26 Jan, 2016

Dudley B writes:

I'm a Business Analyst trying to learn how to code. Luckily there's Python, a suitable language for absolute beginners like me. Thank God also for your book, Python for Kids. It's a great book which explains Python fundamentals in a fun and easy way. In Chapter 14 of the book, page 208, there is a parameter called "evt":

def turn_left(self, evt):
    self.x = -2
def turn_right(self, evt):
    self.x = 2

I can't figure out what this parameter is for, and why it's there since there is no value passed on to it. Please help me understand why "evt" is needed for those functions.

The evt parameter isn't brilliantly explained in that chapter, now that I look back at it. If you go back to the section titled "Making an object React to something" in Chapter 12, there's a description there of event bindings. The function described takes a parameter called event. After you've "told" tkinter about the function (that's the binding part), when an event occurs (such as the mouse being moved, or keyboard being pressed) it calls that function with an object containing more information (such as what sort of event it was).

The parameter evt on page 208, is simply a shortened name for the parameter event mentioned in the earlier chapter. In fact, the name isn't important at all -- you could even call it bob, or aardvark, or anything else you like.

By the way, another way of thinking about the tkinter event binding is that it's like a contract between two people. Let's say between a surfer, and an old man living on a cliff above the sea. The surfer says to the old man, "send me a message and let me know how high the surf is, whenever it changes". The function is that contract, and the message about the surf is the parameter value.

Hopefully that helps.