Title: Variables
Course: COP1000: Introduction to Programming > Section: Module Five

Introduction

A data type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored.

There are three basic types of data in a computer: real numbers and/or integers, characters, and booleans. A real number is a value that represents a quantity along a continuous line. The real numbers include all the rational numbers and the fractions, and all the irrational numbers. Real numbers can be thought of as points on an infinitely long line called the number line or real line, where the points corresponding to integers are equally spaced. Characters may contain a single letter, digit, punctuation mark, symbol, formatting code, control code, or some other specialized code. Characters are combined to form strings. They are commonly represented using ASCII or UNICODE. Boolean values can only be true or false, 1 or 0, on or off, etc.

The point of declaring variables is to store values. To store a value in a variable first the variable needs to be declared then the value assigned to the variable. As an example "var number = 10", in this code snippet a variable of type var names number is assigned the value of 10. (http://en.wikipedia.org/wiki/Data_type)

Objectives

Upon completion of this module, the student will be able to:

Define the following: "Data type", "real numbers", "integers", "characters", and "Booleans"
Specify the purpose of a variable
Declare and store a variable of each type

Readings & Resources

Chapter 2: The Interactive Shell p. 8-16
Chapter 3: Strings, and your First Program p. 18-19