Python

What is Python?

"Python is an object-oriented, high-level programming language. Object-oriented means this language is based around objects (such as data) rather than functions, and high-level means it's easy for humans to understand.

Python is used to create web and mobile software, in artificial intelligence (AI) and machine learning (ML), to perform data manipulation and analysis, and much much more." - source: www.datacamp.com

One of the "much much more" is Python for "DevOps Engineers". It's popular among DevOps Engineers due to its simplicity, versatility, and extensive library support. It can be used in various aspects of the DevOps workflow such as:

  1. Automation

  2. Configuration Management

  3. Infrastructure Provisioning

  4. Continuous Integration and Deployment (CI/CD)

  5. Monitoring and Logging

  6. Cloud Services and APIs

  7. Containerization and Orchestration

  8. Testing and Quality Assurance

  9. Data Analysis and Visualization

With its extensive library ecosystem and versatility, Python proves to be an invaluable asset for DevOps engineers. It empowers them to automate workflows, efficiently handle infrastructure management, and seamlessly integrate diverse tools and services into their DevOps pipelines.


Task:

Install Python

I ended up installing Python on Linux (Ubuntu). Here are the steps that I took. I first used the command "sudo apt-get update" - this downloads the package lists from the repos and updates them to get information on the newest versions of the packages. I then used the Linux command "sudo apt install python3" to install Python on Linux and confirmed by checking the latest version installed with the command "python3 --version". See below:

ubuntu@ip-172-31-92-141:~$ sudo apt-get update
Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done                          

ubuntu@ip-172-31-92-141:~$ sudo apt install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.10.6-1~22.04).
python3 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.

ubuntu@ip-172-31-92-141:~$ python3 --version
Python 3.10.6
ubuntu@ip-172-31-92-141:~$

Data Types in Python

Image of Python Data Types Chart - https://www.javatpoint.com/python-data-types

Python has several built-in data types that allow you to store and manipulate different kinds of data. Data types in Python form the basis for storing and manipulating data in various formats. Python also allows one to create custom data types using classes and objects through Object Oriented Programming (OOP). Here are the fundamental data types in Python:

  1. Numeric Types:

    1. Integer int: whole numbers such as -1, 0, 3, etc.

    2. Float float: decimal numbers such as -1.5, 0.0, 3.1, etc.

    3. Complex complex: consists of a real part & an imaginary part. It's defined in the form of "a + bj" - "a" represents the real part, b represents the imaginary part, and j represents the imaginary unit.

  2. Set Type set:

    Represents an unordered collection of unique elements. They are useful for tasks involving membership testing, removing duplicates, and performing mathematical set operations.

    Membership refers to the act of determining whether an element belongs to a set.

  3. Boolean Type bool:

    Represents the True or False values. It's used for logical operations and control flow.

  4. Mapping Type - Dictionary dict:

    Represents a collection of key-value pairs. Dictionaries are unordered, mutable and provide fast access to values based on keys.

    Mutable Objects can be modified after creation.

    Immutable Objects cannot be modified once they are created.

  5. Sequence Types:

    1. String str: sequence of characters such as "I like DevOps".

    2. List list: ordered collection of items which can contain different data types and are mutable.

    3. Tuple tuple: ordered collection of items, however, tuples are immutable.


I appreciate your busy time reading this short blog. As I continue with my journey to learn and acquire the skill set of a DevOps Engineer, I will share what I learn. Thank you.

Happy Learning!


Sam Samarullah

LinkedIn

Previous Blog