Day 13: Basic Python and Different Data Types in Python.

Day 13: Basic Python and Different Data Types in Python.

Here I have covered the need of Python in DevOps, Basics of Python, its different data types of Python.

Tasks:

  • Install Python in your respective OS, and check the version.

  • Read about different Data Types in Python.

What is need of Python in DevOps?

  • Automation: Python is an excellent language for automation. DevOps engineers use Python to automate repetitive tasks like deployment, testing, and configuration management. Python provides several modules and libraries for automation, such as Ansible, Fabric, and Puppet.

  • Infrastructure as Code(IaC): Python can be used for Infrastructure as Code tasks to automate the entire infrastructure setup.

  • Testing: Python provides a range of testing frameworks for automated testing in DevOps.

  • Data analysis and visualization: DevOps engineers use Python to analyze log files, track application performance, and create dashboards.

  • Integration: Python has a rich set of libraries and tools that can be used for integration with other tools and systems. DevOps engineers use Python to integrate various tools in their DevOps pipeline, such as Jenkins, Docker, Kubernetes, and AWS.

What is Python?

  • Python is Open source, general purpose, high-level, and object-oriented programming language.

  • It was created by Guido van Rossum.

  • Python consists of vast libraries and various frameworks like Django, Tensorflow, Flask, Pandas, Keras etc.

Tasks:

Install Python in your respective OS, and check the version.

Step 1:

Python Version

Step 2:

Python Installation


Different Data Types in Python.

Python-Data-Types-Overview

String:

  • A String is a collection of one or more characters put in a single quote, double quote or triple quote.
# DataType Output: str
x = "Hello World"

Integer:

  • It contains positive and negative whole numbers(without fractions or decimals).
# DataType Output: int
x = 50

float:

  • It is a real number with a floating-point representation.It is specified by the decimal points.
# DataType Output: float
x = 60.5

Complex Number:

  • It is specified as (real part) + (imaginary part).
# DataType Output: complex
x = 3j+2

list:

  • Lists are just like arrays, declared in another language which is an ordered collection of data.
# DataType Output: list
x = ["geeks", "for", "geeks"]

Tuples:

  • Just like a list, a tuple is also an ordered collection of Python objects. The only difference between a tuple and a list is that tuples are immutable i.e. tuples cannot be modified after it is created.
# DataType Output: tuple
x = ("geeks", "for", "geeks")

Dictionary:

  • A dictionary in Python is an unordered collection of data values, used to store data values like a map, unlike other Data Types that hold only a single value as an element, a Dictionary holds a key: value pair.

  • Key-value is provided in the dictionary to make it more optimized.

# DataType Output: dict
x = {"name": "Suraj", "age": 24}

Set:

  • A Set is an unordered collection of data types that is iterable, mutable and has no duplicate elements.
# DataType Output: set
x = {"geeks", "for", "geeks"}

Boolean:

  • Data type with one of the two built-in values,True or False.
# DataType Output: bool
x = True

Happy Learning :)

Did you find this article valuable?

Support Rohit Rajput by becoming a sponsor. Any amount is appreciated!