Python Data Types

Data types specify the type of data that a variable can hold. Python has various built-in data types that allow you to work with different kinds of data effectively.

Common Data Types in Python

  1. Numeric Types: Integers, Floating-Point Numbers, and Complex Numbers
  2. Sequence Types: Strings, Lists, and Tuples
  3. Mapping Type: Dictionaries
  4. Set Types: Sets and Frozensets
  5. Boolean Type: Booleans
  6. Binary Types: Bytes, Byte Arrays, and Memory Views

Numeric Types

1. Integers

Integers are whole numbers, both positive and negative, without a fractional part.

Python

Tutorials dojo strip

2. Floating-Point Numbers

Floating-point numbers are real numbers with a decimal point.

Python

3. Complex Numbers

Complex numbers are written with a real part and an imaginary part.

Python

Sequence Types

1. Strings

Strings are sequences of characters enclosed in single or double quotes.

Python

2. Lists

Lists are ordered, mutable collections of items.

Python

3. Tuples

Tuples are ordered, immutable collections of items.

Python

Mapping Type

1. Dictionaries

Dictionaries are unordered collections of key-value pairs.

Python

Set Types

1. Sets

Sets are unordered collections of unique items.

Python

2. Frozensets

Frozensets are immutable sets.

Python

Boolean Type

1. Booleans

Booleans represent True or False values.

Python

Binary Types

1. Bytes

Bytes represent sequences of byte (8-bit) values.

Python

2. Byte Arrays

Byte arrays are mutable sequences of byte values.

Python

3. Memory Views

Memory views allow you to access the internal data of an object that supports the buffer protocol.

Python

Python Data Types Example Code

This example demonstrates how to define and print variables of different data types in Python.

Python




Python Labs

Tutorials dojo strip