Skip to main content

Command Palette

Search for a command to run...

Day 14 - Task: Exploring Python Data Types and Data Structures for DevOps 🐍(Dec 10, 2023)

Updated
β€’2 min read
Day 14 - Task: Exploring Python Data Types and Data Structures for DevOps 🐍(Dec 10, 2023)

New day, New Topic.... Let's learn along πŸ˜‰

Data Types in Python

Data types are the building blocks of any programming language, categorizing data items based on the kind of value they represent and the operations that can be performed on them. In Python, everything is treated as an object, and data types are implemented as classes. Here's a glimpse of the built-in data types:

  • Numeric: Integer, Complex, Float

  • Sequential: String, Lists, Tuples

  • Boolean

  • Set

  • Dictionaries

To check the data type of a variable, you can use the type() function:

your_variable = 100
print(type(your_variable))

Data Structures in Python

Data structures organize data for efficient access. They form the foundation of any programming language. Python simplifies learning these fundamentals compared to other languages. Let's explore a few essential data structures:

Lists

Python Lists are ordered collections, similar to arrays in other languages. They're flexible, allowing elements of different types.

Tuple

Tuples are collections of Python objects, like lists, but immutable. Once created, elements cannot be added or removed.

Dictionary

Python dictionaries are like hash tables, offering O(1) time complexity. They store key-value pairs, providing an optimized way to store and retrieve data.

Tasks

Task 1: Differences between List, Tuple, and Set

  • List: Ordered, Mutable

  • Tuple: Ordered, Immutable

  • Set: Unordered, Mutable (No duplicates)

Hands-on: Provide screenshots demonstrating these differences.

Task 2: Using Dictionary Methods

fav_tools = {1: "Linux", 2: "Git", 3: "Docker", 4: "Kubernetes", 5: "Terraform", 6: "Ansible", 7: "Chef"}
# Use dictionary methods to print your favorite tool using keys
print(fav_tools[3])

Task 3: List of Cloud Service Providers

cloud_providers = ["AWS", "GCP", "Azure"]
# Add Digital Ocean to the list and sort alphabetically
cloud_providers.append("Digital Ocean")
cloud_providers.sort()
print(cloud_providers)

Further Exploration

If you want to dive deeper into Python, watch Python tutorials and enhance your skills. Share your learning journey on LinkedIn and tag us along! πŸ˜ƒ

Happy learning, and keep exploring the vast world of Python in DevOps! πŸš€πŸŒπŸ

More from this blog

DevOps Journey with M Hassan

174 posts

I am writing these blogs because I recently completed a comprehensive DevOps course where I gained in-depth knowledge of the topics mentioned. As I progressed through the course, I realized the importance of having a concise and accessible resource to revise and reinforce my understanding of each topic. Therefore, I decided to create cheat sheets in the form of blog posts. These cheat sheets will not only serve as a handy reference for myself but also benefit others who are also interested in mastering DevOps concepts. By documenting each topic and providing concise explanations, I aim to create a valuable resource that simplifies complex concepts and facilitates hands-on practice. This way, I can solidify my own understanding while helping others on their DevOps journey.