Skip main navigation

Data types

A summary of common data types in Python

As described in the previous video, behind the scenes Python stores data in different ways depending on it’s type. You often don’t need to worry about this to begin with, and as you improve in programming skills you will get used to the different data types. Below is a summary table of the main ones.

Data type Kind of Data Stored Examples
int Integers – whole numbers 1, 500, 9040
float Fractional numbers 1.1, 500.75, 0.00041
string Text “Hello”
boolean True or False True, False

A slightly more complex data type we often use is called a list. Very simply, this just stores a list of items, from the datatypes above. Let’s see an example:

numbers = [3, 56, 42, 9]

‘numbers’ is variable which holds several individual data items – it holds a list of numbers.

To access the particular member of a list we use square brackets, e.g. to get at the second item we can do

print numbers[2]

This will print “42” – note the counting starts from 0 (item 0 is the first item in a list)

This article is from the free online

Introduction to Image Analysis for Plant Phenotyping

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education