Python Data Types & Data Structures for DevOps
Day 14 for 90daysOfDevOps

Hello, I am sumit and currently pursing my final year of graduation with IT stream from JSPM BSIOTR Wagholi Pune. I am currently learning DevOps with TrainWIthShubham. I have prior knowledge of Java, JSP, Servlet, SQL and Data structure also.I am a hard worker, smart and quick learner.
Python Data Types

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 instance (object) of these classes.
Python has the following data types built-in by default: Numeric(Integer, complex, float), Sequential(string,lists, tuples), Boolean, Set, Dictionaries, etc
Data Structure

Python provides several built-in data structures, which are fundamental for organizing and storing data efficiently. Here are some commonly used data structures in Python:
Lists:
A mutable, ordered sequence.
Created using square brackets
[].Example:
pythonCopy codemy_list = [1, 2, 3, 'hello', 4.5]
Tuples:
An immutable, ordered sequence.
Created using parentheses
().Example:
pythonCopy codemy_tuple = (1, 2, 3, 'world', 4.5)
Sets:
An unordered collection of unique elements.
Created using curly braces
{}or theset()constructor.Example:
pythonCopy codemy_set = {1, 2, 3, 4, 4, 5}
Dictionaries:
A collection of key-value pairs.
Created using curly braces
{}or thedict()constructor.Example:
pythonCopy codemy_dict = {'name': 'John', 'age': 25, 'city': 'New York'}
Strings:
A sequence of characters.
Immutable.
Created using single (
') or double (") quotes.Example:
pythonCopy codemy_string = "Hello, Python!"
Arrays (from the
arraymodule):A more compact way to represent arrays of numeric values.
Example:
pythonCopy codefrom array import array my_array = array('i', [1, 2, 3, 4, 5])
Deque (from the
collectionsmodule):Double-ended queue.
Supports fast appends and pops from both ends.
Example:
pythonCopy codefrom collections import deque my_deque = deque([1, 2, 3, 4, 5])
Stacks (using lists):
LIFO (Last-In, First-Out) data structure.
Implemented using lists.
Example:
pythonCopy codemy_stack = [1, 2, 3] my_stack.append(4) # push top_item = my_stack.pop() # pop
Queues (using lists or
queuemodule):FIFO (First-In, First-Out) data structure.
Example (using lists):
pythonCopy codemy_queue = [1, 2, 3] my_queue.append(4) # enqueue front_item = my_queue.pop(0) # dequeueExample (using
queuemodule):pythonCopy codefrom queue import Queue my_queue = Queue() my_queue.put(1) # enqueue front_item = my_queue.get() # dequeue




