Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22462

Python 4 Kids: Python for Kids Book: Project 10

$
0
0

In these posts I outline the contents of each project in my book Python For Kids For Dummies.  If you have questions or comments about the project listed in the title post them here. Any improvements will also be listed here.

What’s in Project 10 (Math Trainer)

Project 10 is the last of the projects in the book. Project 10 is a math trainer – it tests you on your times tables and prints them out to allow you to revise.  This project is largely an application of some of the earlier work in the book but involves a little added complexity and some thought in solving some user interface issues.  For example, I use a formatting template to present the times tables. It’s easy to print out a long list of the times tables, but not very readable, so I show you how to use a nested loop to present 5 tables at a time across the screen. This uses the slice operator [:] as well as string’s join method

In order to ask random questions I introduce random.choice.  The trainer allows you to compete against yourself on score and on time. In order to time each training session I introduce the time method from the time module – time.time().

There are three additional projects that, as at 8 September 2015, I have completed and am now waiting to be loaded online.

Improvements:

@306: The time module gives you the number of seconds since the Epoch. The Epoch started on 1 January 1970 (for Unix operating systems). Why is it 1 January 1970? No reason. It’s just one of those historical accidents that infest everything to do with time calculations.



Viewing all articles
Browse latest Browse all 22462

Trending Articles