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

Basic functions


We learned at the beginning of this chapter that the first electronic calculator had four basic functions: addition, subtraction, multiplication, and division. We will be working on programming each of these functions, and we will also learn a fifth mathematical function that we can program for our calculator called modulo.

Through the beginning of this chapter, we will use the addition() function as our example. Once we have created and tested an addition() function that does what we want it to, we will then build our other functions.

Let's return to our example of the addition function in Chapter 2, Variables, Functions, and Users. Recall how we programmed this function:

The addition function in the preceding screenshot does perform proper addition and prints the answer. However, there are problems with designing an addition() function this way. One problem is that the program can only add the same two numbers over and over again. Another problem is that, in this program,...