Book Image

Python Projects for Kids

By : Jessica Ingrassellino
Book Image

Python Projects for Kids

By: Jessica Ingrassellino

Overview of this book

Kids are always the most fast-paced and enthusiastic learners, and are naturally willing to build stuff that looks like magic at the end (when it works!). Programming can be one such magic. Being able to write a program that works helps them feel they've really achieved something. Kids today are very tech-savvy and cannot wait to enter the fast-paced digital world. Because Python is one of the most popular languages and has a syntax that is quite simple to understand, even kids are eager to use it as a stepping stone to learning programming languages. This book will cover projects that are simple and fun, and teach kids how to write Python code that works. The book will teach the basics of Python programming, installation, and so on and then will move on to projects. A total of three projects, with each and every step explained carefully, without any assumption of previous experience.
Table of Contents (18 chapters)
Python Projects for Kids
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

pygame


To test the pygame functions, open your text editor, create a file called sample.py, and save this file in your work folder. Once you have created this file, you are ready to start learning pygame. To use pygame, we will import the pygame module in the first line of our sample.py file:

import pygame

Initializing pygame

Next, we need to take a look at the methods that we need in order to start our instance of pygame. To start pygame, we need to initialize an instance of all the pygame modules. We do this by calling the init() function:

pygame.init()

A pygame game loop is the same as the game loops that we used in previous projects. In this chapter, it will be a while loop that uses while True in order to indicate that the game loop should repeat itself over and over again until it is stopped:

Setting up the game screen – size

Once we have pygame set up and initialized, we will want to know how to make a basic background screen. First, you will learn how to set the size of our screen. Then...