PROJECT 10

Math Trainer

Do you want a chance to be the teacher? This project tests users on their times tables and displays times tables so a user can practice. It keeps score and records how long it took to take the test.

image

Here’s where you put your class skills to the test and give your brain a workout.

Planning Your Math Trainer

Your math trainer should ask for answers about the times tables (from 1 through 12) and make sure the answer is right.

But does your best friend need help memorizing the tables? The math trainer could print out a times table. Maybe your other BFF knows the smaller numbers already, so the trainer should set a bottom limit (just avoid the 1s, for instance). If you like, you can add a higher upper limit than 12.

Add a score and time how long it takes to take the test. Game on!

Setting Up

Set up your file and put some code in that asks a question and works out whether the answer is correct.

Do the following to get the project up and running:

  1. Create a new file called math_trainer.py.
  2. Create a module docstring for the file.
  3. Use a hash comment to mark these sections: Imports, Constants, Function, and Testing.

    You know from the silly sentences project that if you put a tuple after a formatting operator %, Python unpacks the tuple into formatting specifiers in the formatting string. That means that "What is %sx%s?"%(4,6) becomes "What is 4x6?". You’re ...

Get Python For Kids For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.