Chapter 3. Silly Sentence Generator 3000: creating interactive programs
- Create a welcome message for a game
- Add notes to your code
- Ask users to input (or type in) information and save it using variables
- Join strings
- Display information back to the user based on that information
Visit a website, start up a game system, or open a mobile application, and it will probably ask you to enter a name and email address and create a password. These are all computer programs, and once you’re logged in, they may display special messages at the top of the screen saying things like “Welcome, Aaron” (or whatever your name is). Some programs are very sophisticated, remembering the games you’ve played, the badges you’ve earned, the balance in your account, or the products you’ve viewed.
iTunes, Netflix, Facebook, and Gmail are all sites that use computer programs that ask you for information, save information, and interact with you based on that information. In this chapter, you’ll see how to do this with Python by creating a ridiculously fun word game called Silly Sentence Generator 3000.
In Silly Sentence Generator 3000, the game player (that’ll be you) is asked to enter words such as nouns, verbs, adjectives, and so on. You’ll store the words as variables and then use them to create ridiculous, nonsensical sentences.[1] Figure 3.1 shows an example of what the finished program looks like.