# Python Data Types & Data Structures for DevOps

### Python Data Types

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1703003612410/a5e71d32-6317-4f5c-b1ab-049e7dc24c64.png align="center")

* Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data.
    
* Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.
    
* Python has the following data types built-in by default: Numeric(Integer, complex, float), Sequential(string,lists, tuples), Boolean, Set, Dictionaries, etc
    

### Data Structure

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1703003929582/96110f48-83ac-4587-a9d4-c5f731888776.png align="center")

Python provides several built-in data structures, which are fundamental for organizing and storing data efficiently. Here are some commonly used data structures in Python:

1. **Lists:**
    
    * A mutable, ordered sequence.
        
    * Created using square brackets `[]`.
        
    * Example:
        
        ```plaintext
        pythonCopy codemy_list = [1, 2, 3, 'hello', 4.5]
        ```
        
2. **Tuples:**
    
    * An immutable, ordered sequence.
        
    * Created using parentheses `()`.
        
    * Example:
        
        ```plaintext
        pythonCopy codemy_tuple = (1, 2, 3, 'world', 4.5)
        ```
        
3. **Sets:**
    
    * An unordered collection of unique elements.
        
    * Created using curly braces `{}` or the `set()` constructor.
        
    * Example:
        
        ```plaintext
        pythonCopy codemy_set = {1, 2, 3, 4, 4, 5}
        ```
        
4. **Dictionaries:**
    
    * A collection of key-value pairs.
        
    * Created using curly braces `{}` or the `dict()` constructor.
        
    * Example:
        
        ```plaintext
        pythonCopy codemy_dict = {'name': 'John', 'age': 25, 'city': 'New York'}
        ```
        
5. **Strings:**
    
    * A sequence of characters.
        
    * Immutable.
        
    * Created using single (`'`) or double (`"`) quotes.
        
    * Example:
        
        ```plaintext
        pythonCopy codemy_string = "Hello, Python!"
        ```
        
6. **Arrays (from the** `array` **module):**
    
    * A more compact way to represent arrays of numeric values.
        
    * Example:
        
        ```plaintext
        pythonCopy codefrom array import array
        my_array = array('i', [1, 2, 3, 4, 5])
        ```
        
7. **Deque (from the** `collections` **module):**
    
    * Double-ended queue.
        
    * Supports fast appends and pops from both ends.
        
    * Example:
        
        ```plaintext
        pythonCopy codefrom collections import deque
        my_deque = deque([1, 2, 3, 4, 5])
        ```
        
8. **Stacks (using lists):**
    
    * LIFO (Last-In, First-Out) data structure.
        
    * Implemented using lists.
        
    * Example:
        
        ```plaintext
        pythonCopy codemy_stack = [1, 2, 3]
        my_stack.append(4)  # push
        top_item = my_stack.pop()  # pop
        ```
        
9. **Queues (using lists or** `queue` **module):**
    
    * FIFO (First-In, First-Out) data structure.
        
    * Example (using lists):
        
        ```plaintext
        pythonCopy codemy_queue = [1, 2, 3]
        my_queue.append(4)  # enqueue
        front_item = my_queue.pop(0)  # dequeue
        ```
        
    * Example (using `queue` module):
        
        ```plaintext
        pythonCopy codefrom queue import Queue
        my_queue = Queue()
        my_queue.put(1)  # enqueue
        front_item = my_queue.get()  # dequeue
        ```
