Day 13 of #90daysofdevops
Hey Techies! Welcome to this blog
In this blog, we are going to start Python for DevOps.
What is Python?
Python is an Open source, general-purpose, high-level, object-oriented and interpreted programming language.
It is a case-sensitive programming language.
Python is easy to learn and is widely used among developers.
The major focus behind creating it is making it easier for developers to read and understand, also reducing the lines of code.
Python is known for its ease of use, powerful standard library, and dynamic semantics.
What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping or production-ready software development.
Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has a syntax that allows developers to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a functional way.
Install Python in your respective OS, and check the version.
For Linux (Ubuntu/Debian):
Python often comes pre-installed in many Linux distributions. You can check by opening the terminal and typing python3 --version
. If it's not installed, you can install it using the package manager.
sudo apt update
sudo apt install python3
Then, check the installed Python version with python3 --version
.
Read about different Data Types in Python.
Python, being a dynamically typed language, supports various data types. Here are some common ones:
Integers (
int
): Whole numbers without a fractional component. Example:x = 5
Floating-Point Numbers (
float
): Numbers with a decimal point or in exponential form. Example:y = 3.14
Strings (
str
): Ordered sequence of characters enclosed within single, double, or triple quotes. Example:name = 'Alice'
Boolean (
bool
): Represents True or False values. Example:is_valid = True
Lists (
list
): Ordered, mutable collection of elements enclosed in square brackets and separated by commas. Example:my_list = [1, 2, 3, 'hello']
Tuples (
tuple
): Ordered, immutable collection of elements enclosed in parentheses and separated by commas. Example:my_tuple = (1, 2, 'hi')
Dictionaries (
dict
): Collection of key-value pairs enclosed in curly braces{}
. Example:my_dict = {'name': 'Bob', 'age': 25}
Sets (
set
): Unordered collection of unique elements enclosed in curly braces{}
. Example:my_set = {1, 2, 3, 4}
None Type (
None
): Represents the absence of a value. Example:result = None
Python also supports type conversion functions like int()
, float()
, str()
, list()
, tuple()
, dict()
, set()
, etc., to convert between different data types.
Thank you so much for taking the time to read till the end! Hope you found this blog informative and helpful.
Feel free to explore more of my content, and don't hesitate to reach out if need any assistance from me or in case of you have any questions.
Happy Learning!
~kritika :)