Reader small image

You're reading from  Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

Product typeBook
Published inSep 2015
Reading LevelBeginner
Publisher
ISBN-139781783551590
Edition1st Edition
Languages
Right arrow
Author (1)
Dan Nixon
Dan Nixon
author image
Dan Nixon

Dan Nixon is a software and electronics engineer living in the north of England. He has past experience of creating software for data analysis, process control, and business intelligence applications. In most of these projects, Python was one of the main languages used. Dan previously authored another book on the uses of the Raspberry Pi, called Raspberry Pi Blueprints, and has worked on many personal projects that use both Python and the Raspberry Pi.
Read more about Dan Nixon

Right arrow

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)
Published in: Sep 2015Publisher: ISBN-13: 9781783551590

Author (1)

author image
Dan Nixon

Dan Nixon is a software and electronics engineer living in the north of England. He has past experience of creating software for data analysis, process control, and business intelligence applications. In most of these projects, Python was one of the main languages used. Dan previously authored another book on the uses of the Raspberry Pi, called Raspberry Pi Blueprints, and has worked on many personal projects that use both Python and the Raspberry Pi.
Read more about Dan Nixon