Python Data Types and Data Structures for DevOps

👉What is Data types in Python?
Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instances (object) of these classes. The following are the standard or built-in data types in Python:
Numeric
Sequence Type
Boolean
Set
Dictionary
Binary Types( memoryview, bytearray, bytes)

👉What is Data structure in Python?
The basic Python data structures in Python include list, set, tuples, and dictionary. Each of the data structures is unique in its own way. Data structures are “containers” that organize and group data according to type. The data structures differ based on mutability and order.
👉Difference between List , Tuple and Dictionary:-
Let's delve into the differences between List, Tuple, Set, and Dictionary in Python:
| Parameters | List | Tuple | Dictionary |
| Basics | A list is similar to an array in other languages (like ArrayList in Java or vector in C++). | Tuples are collections of Python objects separated by commas. | A dictionary in Python is an unordered collection used for storing key: value pairs. |
| Homogeneity | A list is a non-homogeneous data structure that stores elements in columns and rows. | A tuple is a non-homogeneous data structure that stores elements in columns and rows. | A dictionary is a non-homogeneous data structure that stores key-value pairs. |
| Representation | A List is represented by [ ] | A Tuple is represented by ( ) | A Dictionary is represented by { } |
| Duplicate elements | It permits duplicate elements. | It permits duplicate elements. | It does not permit duplicate keys. |
| Nested Among All | It can be nested in a List. | It can be nested in a Tuple. | It can be nested in a Dictionary. |
| Example | [1, 2, 3, 4, 5] | (10, 20, 30, 40, 50) | {1: 'one', 2: 'two', 3: 'three'} |
| Function for Creation | A list can be created using the list() function. | A tuple can be created using the tuple() function. | A dictionary can be created using the dict() function. |
| Mutation | It is mutable, allowing modifications. | It is immutable, not allowing modifications. | It is mutable, but the keys cannot be duplicated. |
| Order | It maintains order. | It maintains order. | It maintains order. |
👉Create a Dictionary and use Dictionary methods to print your favourite tool just by using the keys of the Dictionary?

O/p:-

👉Create a List of cloud service providers? Write a program to add Digital Ocean to the list of cloud_providers and sort the list in alphabetical order.?

O/p:-

I hope this article will help you and me to learn more about the Python Programming.
HAPPY LEARNING.


