Chapter 2
Variables, Data Types, and Constants
IN THIS CHAPTER
Declaring your variables
Defining data types
Storing data in and retrieving data from a variable
Using constant values in variables
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access