Chapter 11

Writing Programs in Python

In This Chapter

arrow Accepting user input and printing to the screen

arrow Using variables, strings, lists, and dictionaries

arrow Using for and while loops

arrow Using conditional statements for decision-making

arrow Creating and using your own functions

In this chapter, we introduce you to Python, a powerful programming language that’s widely used commercially.

One of the best ways to learn programming is to study other people’s programs, so in this chapter, we talk you through two different programs. One is a simple calculator for multiplication tables. The other is an artificial intelligence simulation that enables you to chat with your Raspberry Pi.

You’ll probably find it easiest to learn if you try creating the examples with us, but you can also download the finished programs from the book’s website. For more information on accessing this book’s website, see the Introduction.

In a book of this size, it’s not possible to cover everything you can do with Python, but ...

Get Raspberry Pi For Dummies, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.