Skip to main content
  1. Courses/
  2. Python/

Data Types

·339 words·2 mins· loading · loading ·
Russell Chubb
Author
Russell Chubb
Working at the intersection of Technology and Art.

Data Types
#

Understanding data types is fundamental to programming in Python, as they determine the kind of operations you can perform on your data.

In Python, everything is an object, and data types are classes with variables as instances of these classes. Python has several built-in data types, and today, we’ll cover the most commonly used ones.

The first data-type I’ll be covering are numeric data types, starting with integers, which are whole numbers, both positive and negative, without a decimal point.

Floats (or floating point values) are numbers with a decimal point.

Python also supports complex numbers, which are written with a “j” as the imaginary part.

The next data-type are strings, which are sequences of characters, used to represent text. Strings can be enclosed in single quotes, double quotes, or triple quotes for multi-line strings.

The Boolean data-type represents one of two values: True or False. Booleans are often used in conditional statements.

Lists are sequence data-types, and are ordered, mutable collections of items, which in Python, can be different data-types.

NOTE: If something is mutable, it means it can be changed after creation.

Tuples are similar to lists, but are immutable, meaning they cannot be changed once created. Finally, ranges represent a sequence of numbers and are often used in loops.

A mapping data type, such as a dictionary, stores data as key-value pairs in an unordered, and mutable format, allowing for efficient retrieval, insertion, and deletion of values based on unique keys.

Set Types, such as Sets, are unordered, mutable, collections of unique items.

Frozen sets are similar to sets, but they are immutable.

Finally, the “none” data-type, represents the absence of a value or a null value, which you might use for default function arguments, initializing variables that will be assigned later, or indicating the end of lists in data structures.

That wraps up our overview of the basic data types in Python. Understanding these data types and how to use them is crucial for writing effective Python code.

Thank you for watching.

Related