Book Image

Raspberry Pi Projects for Kids (Second Edition)

By : Daniel Leonard Bates
Book Image

Raspberry Pi Projects for Kids (Second Edition)

By: Daniel Leonard Bates

Overview of this book

Table of Contents (14 chapters)

The program we're going to use to generate phrases

As mentioned earlier, our program is going to generate random, possibly funny, phrases for us. To do this, we're going to give each phrase a common structure, and randomize the word that appears in each position. Each phrase will look like:

<name> has a <adjective> <noun>

Where <name> is replaced by a person's name, <adjective> is replaced by a descriptive word, and <noun> is replaced by the name of an object.

This program is going to be a little larger than our previous code example, so we're going to want to save it and modify it easily. Navigate to File | New Window in Python 2. A second window will appear which starts off completely blank. We will write our code in this window, and when we run it, the results will appear in the first window. For the rest of the chapter, I will call the first window the Shell, and the new window the Code Editor. Remember to save your code regularly!


We're going to...