O'Reilly logo

Teach Your Kids to Code by Bryson Payne

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Numbers and Variables: Python Does the Math

We’ve used Python to do really fun things, like make colorful pictures in just a few lines of code, but our programs have been limited. We just ran them and watched them make pictures. What if we wanted to interact with our Python programs? In this chapter, we’ll learn how to have Python ask the user’s name and even offer to do the user’s math homework!

Variables: Where We Keep Our Stuff

In Chapter 1 and Chapter 2, we used a few variables (you might remember name from our first program in Chapter 1 or x and sides from Chapter 2). Now let’s look at what variables really are and how they work.

A variable is something you want the computer to remember while your program is running. When Python “remembers” ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required