Chapter 2. Variables

Table of Contents

2.1. Data, values and types of values
2.2. Variables or naming values
2.3. Variable and keywords, variable syntax
2.4. Namespaces or representing variables
2.5. Reassignment of variables

2.1. Data, values and types of values

In the first session we have explored some basic issues about a DNA sequence. The specific DNA sequence 'atcgat' was one of our data. For computer scientists this is also a value. During the program execution values are represented in the memory of the computer. In order to interpret these representations correctly values have a type.

Type

Types are sets of data or values sharing some specific properties and their associated operations.

We have modeled the DNA sequence, out of habit, as a string. [1] Strings are one of the basic types that Python can handle. In the gc calculation we have seen two other ones: integers and floats. If you are not sure what sort of data you are working with, you can ask Python about it.

>>> type('atcgat')
<type 'str'>
>>> type(1)
<type 'int'>
>>> type('1')
<type 'str'>