O'Reilly logo

Python Projects for Kids by Jessica Ingrassellino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Section 1 – imports, globals, and drawings

In this first section, we will write all of the code to set up the different parts of our game. This includes importing libraries, defining all of our global variables, and telling the computer how to draw the screen, ball, and paddles.

Importing libraries

The first lines of code we write will be used to import the necessary libraries into the game, including pygame. We will be using three libraries in the game: pygame, math, and random. pygame, as we discussed in the previous chapter, allows us to have visual elements in our game. The random library, included with Python, gives us the ability to select and use random numbers in our game. The math library, also included with Python, allows for mathematics ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required