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

Bringing back the while loop


So, you may remember using the while loop back in Chapters 4, Making Decisions: Python Control Flows, and Chapter 5, Loops and Logic. We will be using the while loop again to set up the game loop. There is quite a lot happening in the game loop (the while loop), so let's take a look at it step by step. First, look at this screenshot of all of the code inside the game loop:

The first thing that you see is the comment telling anybody who reads the code what the code is doing. Comments are not required, but sometimes they can be helpful when you are writing a program. This comment simply tells us that the next section is the game loop.

The game loop starts with the game_on variable. The game_on variable is set to equal True (remember, True is a Boolean). The next line says while game_on:; this means that since the while loop is True, keep running the while loop until something happens to make it False (untrue). Since while game_on: is True, the game will keep running...