beautypg.com

5 introduction to python, 1 data types – Rainbow Electronics GM862-GPS User Manual

Page 14

background image





Easy Script

in Python

80000ST10020a Rev.8 - 01/10/08

Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved

page 14 of 100

1.5 Introduction to Python


Python is a dynamic object oriented programming language that can be used for many kinds of
software development. It offers strong support for integration with different tools, comes with extensive
standard libraries, and can be learned in a few days time.

1.5.1 Data types

There are three groups of data types in Python:

• Scalars have the subtypes integer, long integer (with an arbitrary number of digits), and strings.

For example:

i = 1; li = 9999999999L; s = 'Hello'

• Sequences contain any number of arbitrary objects in a defined order.

L = [1, 5, 3, 9, 14];

• Associative lists (more commonly known as dictionaries) allow the access to values based on

keys. These keys can be arbitrary but immutable objects. For example:

D = {'b': 'Python', 'a': 5}; print D['a']

prints 5.

• Unlike Pascal, C, C++ or Java, Python is a dynamically typed language. Thus, the following

code is perfectly valid Python:

a = 7 # 7 (integer)
a = str(2*a) + ' bytes' # '7 bytes' (string)

In Python variables are not defined in the script, they appear only when used.