Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By : Dan Nixon
Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By: Dan Nixon

Overview of this book

Table of Contents (18 chapters)
Getting Started with Python and Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Data in Python


Before jumping to the various data types that are available in Python, it is worth noting that Python is a strong dynamically typed programming language, which means both that:

  • Once a variable (a unit of stored data in a program) has been given a value, its type is set and will not change until the variable is assigned a value of a different type (strong)

  • A variable can hold a value of any type as the type is given by the value, not the variable itself (dynamic)

This is best explained with an example that can be executed from the interactive console, assuming we have a variable representing a string:

flan = "flan"

We can query the value held by the variable and the type using the following code (note that this will only work on an interactive console as return values are automatically printed to the terminal):

flan
type(flan)

As the following output shows, the variable is of type str which represents a string in Python:

We can now reassign the variable to a new numerical value and...