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:
Automation
Configuration Management
Infrastructure Provisioning
Continuous Integration and Deployment (CI/CD)
Monitoring and Logging
Cloud Services and APIs
Containerization and Orchestration
Testing and Quality Assurance
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
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:
Numeric Types:
Integer
int
: whole numbers such as -1, 0, 3, etc.Float
float
: decimal numbers such as -1.5, 0.0, 3.1, etc.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, andj
represents the imaginary unit.
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.
Boolean Type
bool
:Represents the True or False values. It's used for logical operations and control flow.
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.
Sequence Types:
String
str
: sequence of characters such as "I like DevOps".List
list
: ordered collection of items which can contain different data types and are mutable.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!