# Day-15 of #90DaysOfDevOps

# **Basics of Python for DevOps Engineers**

Welcome to Day 15 of my #90DaysOfDevOps journey! Today, we dive into Python basics, covering its installation across various operating systems and a detailed look at its built-in data types.

---

## **What is Python?**

Python is an open-source, general-purpose, high-level, and object-oriented programming language created by **Guido van Rossum**. Its simplicity and versatility make it an ideal choice for DevOps tasks such as automation, configuration management, and infrastructure as code.

Python’s vast ecosystem of libraries and frameworks, like Django, TensorFlow, Flask, Pandas, and Keras, makes it indispensable in modern development and operations.

---

## **Task 1: Installing Python and Checking the Version**

Let’s explore how to install Python and verify its installation on various operating systems.

### **1\. Windows**

* **Step 1:** Download Python from the [official website](https://www.python.org/downloads/).
    
* **Step 2:** Run the installer and check the box **"Add Python to PATH"** before proceeding with the installation.
    
* **Step 3:** Open Command Prompt and type:
    
    ```shell
    python --version
    ```
    

**Example Output:**

```shell
C:\Users\Amitabh> python --version  
Python 3.11.0  
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734624337345/5f723c6f-7bab-4854-819f-0f0641e3dfd0.png align="center")

---

### **2\. Ubuntu/Linux**

* **Step 1:** Open the terminal.
    
* **Step 2:** Update the package list:
    
    ```shell
    sudo apt update  
    ```
    
* **Step 3:** Install Python:
    
    ```shell
    sudo apt install python3  
    ```
    
* **Step 4:** Verify the installation:
    
    ```shell
    python3 --version  
    ```
    

**Example Output:**

```shell
amitabh@ubuntu:~$ python3 --version  
Python 3.8.10  
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734624349338/7e3eb444-3908-4b1e-bdcc-c096ae400896.png align="center")

---

### **3\. macOS**

* **Step 1:** Use the built-in Python or install it using [Homebrew](https://brew.sh/):
    
    ```shell
    brew install python  
    ```
    
* **Step 2:** Verify the installation:
    
    ```shell
    python3 --version  
    ```
    

**Example Output:**

```shell
MacBook-Pro:~ amitabh$ python3 --version  
Python 3.9.7  
```

---

## **Task 2: Understanding Python Data Types**

Python provides a wide variety of built-in data types, enabling flexibility and simplicity in programming.

### **1\. Numeric Types**

* **Integer (**`int`): Whole numbers.
    
    ```python
    age = 25  
    print(type(age))  # Output: <class 'int'>  
    ```
    
* **Float (**`float`): Numbers with a decimal point.
    
    ```python
    pi = 3.14  
    print(type(pi))  # Output: <class 'float'>  
    ```
    
* **Complex (**`complex`): Numbers with real and imaginary parts.
    
    ```python
    complex_num = 3 + 5j  
    print(type(complex_num))  # Output: <class 'complex'>  
    ```
    

---

### **2\. Sequence Types**

* **String (**`str`): A sequence of characters.
    
    ```python
    name = "Amitabh"  
    print(type(name))  # Output: <class 'str'>  
    ```
    
* **List (**`list`): Ordered and mutable collection.
    
    ```python
    fruits = ["apple", "banana", "cherry"]  
    print(type(fruits))  # Output: <class 'list'>  
    ```
    
* **Tuple (**`tuple`): Ordered but immutable collection.
    
    ```python
    coordinates = (10, 20, 30)  
    print(type(coordinates))  # Output: <class 'tuple'>  
    ```
    

---

### **3\. Mapping Type**

* **Dictionary (**`dict`): A collection of key-value pairs.
    
    ```python
    student = {"name": "Amitabh", "age": 21}  
    print(type(student))  # Output: <class 'dict'>  
    ```
    

---

### **4\. Set Types**

* **Set (**`set`): Unordered collection of unique items.
    
    ```python
    colors = {"red", "blue", "green"}  
    print(type(colors))  # Output: <class 'set'>  
    ```
    
* **Frozen Set (**`frozenset`): Immutable version of a set.
    
    ```python
    immut_colors = frozenset(["red", "blue", "green"])  
    print(type(immut_colors))  # Output: <class 'frozenset'>  
    ```
    

---

### **5\. Boolean Type**

* **Boolean (**`bool`): Represents `True` or `False`.
    
    ```python
    is_student = True  
    print(type(is_student))  # Output: <class 'bool'>  
    ```
    

---

### **6\. None Type**

* **NoneType (**`None`): Represents the absence of a value.
    
    ```python
    data = None  
    print(type(data))  # Output: <class 'NoneType'>  
    ```
    

---

### **Summary Table of Data Types**

| Data Type | Example |
| --- | --- |
| `int` | `x = 10` |
| `float` | `pi = 3.14` |
| `complex` | `z = 1 + 2j` |
| `str` | `name = "Amitabh"` |
| `list` | `colors = ["red", "blue"]` |
| `tuple` | `tup = (1, 2)` |
| `dict` | `student = {"key": "value"}` |
| `set` | `unique = {1, 2, 3}` |
| `bool` | `is_ready = True` |

---

Thank you for reading! Python’s simplicity and versatility make it a powerful tool for DevOps engineers, especially in scripting and automation tasks.
