Python 6.2 : Project creation
Time to set up the project for our math game. In PyCharm we click on "New Project", give it a clear name such as math_game and validate. The IDE generates a default sample file: we remove every line it created so we can start from an empty editor and write the program exactly the way we want.
First imports and constants
The very first thing we add is the import for the standard random module. We will use it later on to pick the two operands of each math question, so it is the only library we need at this stage. Importing it now also documents the fact that this project relies on randomness.
import random
MIN = 1
MAX = 10
Right after the import we declare two constants MIN = 1 and MAX = 10. They will be reused everywhere we need to generate a random number for an operand, and centralising them in two named constants makes it easy to change the difficulty of the game later. With this small skeleton in place, the project is ready to grow. In the next video we will write the first exercise that uses these constants to build an addition question.