Chapter 2

Variables, Data Types, and Constants

IN THIS CHAPTER

Bullet Declaring your variables

Bullet Defining data types

Bullet Storing data in and retrieving data from a variable

Bullet Using constant values in variables

Bullet Defining a variable’s scope

Every program consists of a list of instructions that tell the computer what to do. The simplest program consists of a single instruction, such as one that tells the computer to display the words Hello, world! onscreen.

Of course, any program that does the same thing over and over again isn't very useful or interesting. What makes a program useful is when it can accept information from the outside world and then respond to that information.

So, instead of just displaying Hello, world! onscreen, a more useful program might ask for the user to type a name in so the program could display Hello, Bob!

Programs don't always have to get information from a person. Sometimes, programs can retrieve data that’s stored somewhere else, such as a list of employees stored on ...

Get Beginning Programming All-in-One 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.