Data types allow us to categorize and handle different types of values that we can use in our programs.

Each data type has specific characteristics and behaviors that help us to perform operations and data manipulations effectively.

If you want to learn more

consult the **Introduction to Programming Course** read more

## Basic Data Types

### Booleans (`bool`

)

Booleans in Python (`bool`

) are truth values that represent boolean logic. They can be `True`

(true) or `False`

(false) and are used in logical expressions and flow control. For example, in an `if`

statement, it evaluates whether a condition is true or false.

```
true = True
false = False
```

### Integers (`int`

)

Integers in Python (`int`

) are numbers without a decimal point, both positive and negative. They can be of any length and are used to represent whole numbers. Some examples of integers are `5`

, `-10`

, `1000`

, etc.

`integer_number = 10`

### Floating Point Numbers (`float`

)

Floating point numbers in Python (`float`

) are numbers with a decimal point. They can represent both integers and fractions. Some examples of floating point numbers are `3.14`

, `-0.5`

, `2.71828`

, etc.

`float_number = 3.14`

### Strings (`str`

)

Strings in Python (`str`

) are sequences of characters enclosed in single quotes (`'`

) or double quotes (`"`

). They can contain letters, numbers, symbols, and spaces. Some examples of strings are `"Hello"`

, `'Python'`

, `"123"`

, etc.

`string_text = "Hello, world!"`

## Composite Data Types

### Lists (`list`

)

Lists in Python (`list`

) are ordered and mutable collections of elements. They can contain any type of data, including numbers, strings, nested lists, etc. The elements of a list are indexed and can be accessed and modified using indexes.

`my_list = [1, 2, 3, 4, 5]`

### Tuples (`tuple`

)

Tuples in Python (`tuple`

) are ordered and immutable collections of elements. Like lists, they can contain any type of data. The main difference is that the elements of a tuple cannot be modified once the tuple has been created.

`my_tuple = (10, 20, 30, 40, 50)`

### Dictionaries (`dict`

)

Dictionaries in Python (`dict`

) are unordered collections of key-value pairs. Each item in a dictionary has a unique key that is used to access the corresponding value. They are very useful for representing structured and related data.

`my_dictionary = {"name": "John", "age": 30, "city": "Madrid"}`

### Sets (`set`

)

Sets in Python (`set`

) are unordered collections with no duplicate elements. They are used for mathematical set operations such as union, intersection, difference, etc.

`my_set = {1, 2, 3, 4, 5}`