Python Data Types and Data Structures for DevOps

Introduction:
Data Types
Data types classify and categorize data items in Python, determining the type of value and the operations that can be performed on them. In Python, everything is treated as an object, where data types are represented as classes and variables as instances (objects) of these classes. The built-in data types in Python include Numeric types (such as Integer, Complex, and Float), Sequential types (like String, Lists, and Tuples), Boolean, Sets, Dictionaries, and others.
Data Structures
Data Structures are essential tools for organizing and accessing data efficiently in programming. They form the foundation of any program, and Python makes it easier to grasp these fundamentals compared to other languages.
In Python, Lists serve as ordered collections of data, similar to arrays in other languages, providing flexibility with elements of varying types.
Tuples, also collection objects, resemble lists but are immutable, meaning that once created, elements cannot be added or removed. Like lists, tuples can store elements of different types.
Dictionaries in Python act as hash tables, with a time complexity of O(1). They represent an unordered collection of data values and store data in key-value pairs, making them highly optimized for quick access.
Task-1
Give the Difference between List, Tuple and Set.
- Lists:
Lists are ordered collections of elements.
Elements in a list can be of different data types.
Lists are mutable, meaning you can add, remove, or modify elements after creation.
Lists are denoted using square brackets [].
Lists support duplicate elements, and their order is maintained.
Example:
my_list = [1, 'hello', 3.14, True]
- Tuples:
Tuples are similar to lists but are immutable, meaning that once created, elements cannot be changed.
Tuples are generally used when you want to ensure that the data remains constant throughout the program.
Tuples are denoted using parentheses () or can be created without any brackets.
Example:
my_tuple = (1, 'hello', 3.14, True)
- Sets:
Sets are unordered collections of unique elements.
Sets do not allow duplicate elements, and they automatically remove duplicates if added.
Sets are useful for mathematical operations like unions, intersection, etc.
Sets are denoted using curly braces {} or the
set()function.
Example:
my_set = {1, 2, 3, 4}
Task-2
Create the below Dictionary and use Dictionary methods to print your favorite tool just by using the keys of the Dictionary
fav_tools =
{
1:"Linux",
2:"Git",
3:"Docker",
4:"Kubernetes",
5:"Terraform",
6:"Ansible",
7:"Chef"
}

Create a List of cloud service providers eg.
cloud_providers = ["AWS","GCP","Azure"]
Write a program to add Digital Ocean to the list of cloud_providers and sort the list in alphabetical order.

In conclusion, we have embarked on a journey to explore the fundamental concepts of data structures and the exciting realm of cloud service providers using Python. By understanding Lists, Tuples, and Sets, we have gained versatile tools to efficiently organize and manipulate data, optimizing our programming capabilities. Python's user-friendly syntax and support for multiple data types have proven invaluable in our quest for excellence.



