Python Basics.
Table of contents
What is a Code?.
Code is a set of commands (instructions) that is written in a file and this file containing code is given to the Operating System. Now the OS. will understand whether this code is written in English, Marathi, Hindi, or Python. To understand this, the Operating System must have a compiler or interpreter of that language, and then OS does our work.
If one says I don't know to code. It means he is unable to communicate with the interpreter or compiler.
OR,
Coding is a bridge between Computers and humans for Communication.
OR,
Coding is a syntactical set of instructions given to a computer. If the computer understands those sentences it can carry out results. if not it carries out an error.
Why Python is robust for DevOps?
Introduction:-
DevOps engineers interact with Linux systems. In Linux-type systems we generally don't have a graphical user interface to get the information or read the information from the system (like creating a folder, seeing free disk, Memory CPU, etc) because systems are situated remotely from us. So here We need to use the shell command for this.
Now to understand why Python use is necessary in the domain of cloud computing we have to first understand what is Shell Scripting.?
📄Shell-Scripting:-If we create a file and provide the extension of the file (.sh). Instead of providing the extension (.txt) and inside this (.sh) file if we write a bunch of shell commands in order and execute the file, all the commands inside the file will be executed at once.; so by doing this it avoids the repetitive work and helps us to automate our work. The primary purpose of DevOps engineers with Shell Scripting is to interact with Linux-based Systems and get some desired information, or manage the system, etc.
So if we can do all of these things by Shell Scripting. Why do we need Python?
REASON-1:-Shell scripting is only limited to Linux-type systems. Sometimes DevOps engineers also have to interact with Windows systems in the Cloud. For this, we have to learn Python. Python works both on Linux and Windows.
REASON-2:-When we want to write some complex programs (scripting).when we want to interact with APIs.When we want data manipulation. In such cases, we need to use Python.
But Remember these things can also be achieved by shell scripting but Python is built more well for them because Python has a richer module than shell scripting.
In Summary, we can conclude that,
✔️For Simple activities choose Shell Scripting. Like System-related activities;-fetching information, Creating files and folders, and Getting system-related information.
✔️For Complex activities choose Python. Like talking to APIs, Performing operations on the Nested JSON Object, Talking to third-party Applications., and Using the Lambda function when we want to talk to S3 Bucket.