You are on page 1of 1

Python Variables

Variables in the Python language provide the capability of storing data values
while a script is being executed. Variables have a name, type, and value. The
variable name can be any sequence of letters and numbers that start with a letter
and can only include the underscore character. The name is the means for
setting and retrieving stored values, essential to advanced programs. The data
type can be integer, floating-point, String (a series of characters), or more
advanced Python class. The value is an instance of the data type and determines
what types of operations can be computed on it, along with the result of those
operations.
Variables can be set individually, in series, or multiple to the same value. For
claritys sake, variables are most often set individually. Variables are dynamic;
both the value and type of a variable can be changed at any point. Variables can
be set to the result of an operation such as addition or concatenationthe value
and type of the variable would be determined by the output of the operation.
Operators are symbols and associated operations that work on variables and
values. The main built-in operator symbols are +, -, /, *, and %. Each of these
operators performs different computations based on the variables and values
with which they are used in conjunction. These operators have been built to
model their arithmetic meaning, extending their meaning to data types such as
Strings.
Expressions are simple usage of Python operators, methods, and the variables
or values used to compute results. Statements include expressions, but have a
meaning beyond the line of code they are executed. Statements can set
variables to values or import Python scripts or modules.
As stated earlier, variables can be set to a variety of types, both primitive and
object-based. Integers are primitive data types that represent whole numbers.
Floats are primitive data types, which hold decimal numbers. Booleans have
only two allowed values, True or False, useful in determining if actions should be
taken. Strings are text-based values that allow for storing extensive text data for
such actions as logging, web page output, etc. There are a number of built-in
data structures such as tuples, lists, or dictionaries which allow for more
advanced data storage.

You might also like