Day-14:Python Data Types and Data Structures for DevOps

Meenal JyotikaMeenal Jyotika
3 min read

Introduction ๐ŸŽ‰

Hello fellows!

Welcome back to Day 14 of our 90 Days of DevOps Challenge! ๐Ÿš€

Today, we're diving headfirst into the mystical world of Python dictionaries and cloud service providers! Buckle up, because we're about to unravel the secrets of these concepts in our signature simple and comical style.๐Ÿ˜„

Tasks๐ŸŽฏ

  1. The Fantastic Trio of Lists, Tuples, and Sets! ๐Ÿ๐ŸŒ

Before we delve into the magical world of dictionaries and cloud kingdoms, let's warm up our coding muscles with a trio of basic Python data structures: lists, tuples, and sets. Don't worry, we'll keep it as breezy as a gentle spell!

๐ŸŽ List:

Question: Create a Python list named "fruits" containing the names of three different fruits. Print out the second fruit in the list.

Answer:

fruits = ["apple", "banana", "orange"]
print(fruits[1])  # This will print "banana"

๐ŸŒ Tuple:

Question: Define a tuple named "coordinates" with the latitude and longitude values of a location (you can make them up). Access and print the longitude from the tuple.

Answer:

coordinates = (40.7128, -74.0060)  # Example latitude and longitude
print(coordinates[1])  # This will print -74.0060

๐Ÿ”ข Set:

Question: Create two sets, "set1" and "set2," each containing a few numbers. Find and print the intersection of these two sets.

Answer:

set1 = {1, 2, 3, 4}
set2 = {3, 4, 5, 6}
intersection = set1 & set2  # Alternatively, you can use set1.intersection(set2)
print(intersection)  # This will print {3, 4}
  1. Conquering the Dictionary Quest ๐Ÿ“š

Now that we've warmed up, it's time to unveil the mystique of dictionaries! Imagine them as enchanted menus that can conjure items with a mere keyword.

Here's our magical dictionary ready for action:

fav_tools = { 
  1: "Linux", 
  2: "Git", 
  3: "Docker", 
  4: "Kubernetes", 
  5: "Terraform", 
  6: "Ansible", 
  7: "Chef"
}

But how do we summon our favorite tool? Fear not, Python's "dictionary methods" are here to assist us! โœจ

# Let's say your favorite tool number is 2 (Git)
favorite_tool_number = 2
favorite_tool = fav_tools[favorite_tool_number]

print("Your favorite tool is:", favorite_tool)  # Voila! ๐Ÿช„โœจ

With a wave of the code wand... I mean, the use of square brackets, our favorite tool appears! ๐Ÿช„โœจ

  1. Cloudy Cloud Providers ๐ŸŒฉ๏ธ

Now that we've mastered dictionaries, let's soar into the sky of cloud service providers! Think of them as majestic kingdoms in the clouds, where you can store, manage, and explore your applications and data. Our list of cloud providers is like a treasure map to these kingdoms:

cloud_providers = ["AWS", "GCP", "Azure"]

Each cloud provider is a unique castle with its wonders waiting to be discovered!

And guess what? You can embark on quests to these kingdoms using loops. Behold the magic:

print("Embarking on a Cloudy Adventure!")

for provider in cloud_providers:
    print("Visiting the", provider, "Kingdom โ›…")

print("Returned from Cloudy Quests!")

Conclusionโœจ

That's a wrap for today, brave DevOps learners! We've tamed the basics and ventured into the realm of dictionaries and cloud kingdoms. Remember, every day is a chance to conquer new lands in your DevOps adventure.

Stay tuned for Day 15 as we uncover more wonders in the 90 Days of DevOps Challenge.

Until then, keep coding and dreaming of cloud castles! ๐ŸŒŒ๐Ÿ”ฎ

0
Subscribe to my newsletter

Read articles from Meenal Jyotika directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Meenal Jyotika
Meenal Jyotika

AWS-DevOps Engineer:: Automating solutions in a chaotic world:: Epicurean passionate:: Sustainable Cultivator::