DevOps, Day - 14
Please go through Python data types➡️ Here
Data Structures in Python
In Python, a data structure is a way of organizing and storing data in a computer program, so that it can be accessed and used efficiently. Python provides several built-in data structures, including:
Lists: Ordered collection of items, and are mutable (elements can be changed).
Tuples: Ordered collection of items, and are immutable (elements cannot be changed).
Sets: Unordered collection of unique elements, and are mutable.
Dictionaries: Collection of key-value pairs, and are mutable.
Tasks:
Give the Difference between List, Tuple and Set. Do Handson and put screenshots as per your understanding.
List:
Consider the below example, where 'a' contains[23,56,98]
When you try to add value to the List... we can observe ordered elements in the output, as 37 was added in the last, the order of elements in a list is preserved based on the order in which they were added. [Because List is a collection of ordered elements]
Tuple:
consider the below example, where 'a' contains(9,10,11)
As we know tuples are immutable, hence cannot add or remove elements from the tuple.
Set:
consider the below example, where 'a' contains{4,2,7}
When you try to add value to the set... we can observe unordered elements in the output, as 45 was not added in the last, it was added somewhere in the middle**[Because set is a collection of unordered elements]**
When you try to add an already existing element to the set, you can observe unique values.[Because set holds unique values]
Create the below Dictionary and use Dictionary methods to print your favourite tool just by using the keys of the Dictionary.
step 1: Create a dictionary with the above contents
step 2: If you need only key numbers
step 3: if you need only values
step 4: If you need a particular tool from the dictionary
Create a list of cloud service providers eg
cloud_providers = ["AWS", "GCP", "Azure"]
Write a program to addDigital Ocean
to the list of cloud_providers and sort the list in alphabetical order.step 1: create a list with the above-mentioned strings
step 2: Now add
Digital Ocean
to the liststep 3: Now sort in alphabetical order
Thank you so much for reading.
Follow me on LinkedIn to see interesting posts like this : )
Subscribe to my newsletter
Read articles from Vrishni Shree V B directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Vrishni Shree V B
Vrishni Shree V B
💻 Python | Docker | Jenkins | Networking | Git | Linux 💻 Passionate about leveraging technology to drive efficiency and deliver innovative solutions. Proficient in Python development, Docker containerization, Jenkins automation, computer networking, Git version control, and Linux administration. Skilled in collaborating with diverse teams to deliver high-quality software products. Proficient in AWS EC2 instance management and deployment. Seeking new opportunities to apply my expertise and contribute to impactful projects. Let's connect and explore how we can work together! Inter-personal Skills: Communication, Adaptability, Emotional intelligence, Active listening, Collaboration. Happy To Connect🔗😊 Feel free to reach me out😃@ --> vrishnishreevb531@gmail.com 📬