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

Loops


Loops are a kind of control flow, but they rerun the same block of code over and over again until something else tells the loop to stop repeating itself. This is a bit different from conditional statements since these only run the block of code once. The two kinds of loop are while and for. Both types of loop are really useful.

while

while is one kind of loop. When we make a while loop, the program repeats itself until a given block of code happens. When programming a while loop, we need to create some rules, or our program will run forever.

For example, we can make this rule: when the calculator is on, perform the following steps:

  1. Run the calculator.

  2. Prompt the user to keep calculating.

  3. When the user hits the else statement, turn the calculator off.

Let's go through each of the code changes step by step; you will need these changes in order to make the while loop work.

Global variables and the quit() function

We will create a global variable to use in our quit() function. Using the variable...