Chapter 2. 2 simple values, variables, and types: Know Your Value

Image

Computers really only do two things well: store values and perform operations on those values. You might think they’re doing a whole lot more, as you send texts, shop online, use Photoshop, or rely on your phone to navigate in your car; however, everything computers do can be broken down into simple operations that are performed on simple values. Now, part of computational thinking is learning to use these operations and values to build something that is much more sophisticated, complex, and meaningful—and we’re going to get to that. First, though, we’re going to take a look at what these values are, the operations you can perform on them, and just what role variables play in all this.

Coding the Dog Age Calculator

You didn’t think we were going to take you through 50 pages of Python specifications on values and operations before writing some real code, did you? Of course not—we’ve got real work to do!

Up next, the Dog Age Calculator. You already know what the calculator does: you enter a dog’s chronological age and the calculator tells you the dog’s age in relative human years. To perform that calcuation you simply multiply the dog’s chronological age by the number 7. Or, is it that simple? We shall see...

But where do we even start? Do we just start trying to write some code? Well, remember the concept of pseudocode, ...

Get Head First Learn to Code 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.