Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Projects for Kids (Second Edition)

You're reading from   Raspberry Pi Projects for Kids (Second Edition) Leverage the power of programming to use the Raspberry Pi to create awesome games

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781785281525
Length 146 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Daniel Leonard Bates Daniel Leonard Bates
Author Profile Icon Daniel Leonard Bates
Daniel Leonard Bates
Arrow right icon
View More author details
Toc

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime