top of page

Programming with Python Data Types

Python Data Types

Data types simply refer to the 'type' of a piece of data. Python uses five main data types:

- Integer (a whole number). Eg. 2

- Real (a decimal number). Eg. 2.1

- Character (a single character). Eg. 'a'

- String (groups of characters). Eg. 'abc123'

- Boolean (true or false)

All variables in the program would be assigned be of one of the data types above. A variable is a value being used in the program. A variable is usually named and then a value assigned to it.

In Python, integers and reals would be written as they are. However, characters and strings have quotation / speech marks (' ') or (" ") around the data.

It is possible for a variable to be changed to another data type in some cases.

However, it is important to ensure the data type of a variable is correct before carrying out any operations on the data. For example, if a number is stored as a string (so "22" instead of 22), then mathematical operations cannot be carried out on it.

Therefore, data types are important to the functioning of programs in Python.

Thanks ☺️


Recent Posts

See All
bottom of page