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

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

ยท

2 min read

Tasks

Give the Difference between List, Tuple and set.

  • List:

    1. List is an ordered collection of elements.

    2. Lists are mutable, which means you can change, add, or remove elements after creation.

    3. Elements in a list are enclosed in square brackets [ ].

    4. Lists allow duplicate elements.

    5. Lists are useful when you need a dynamic collection that can be modified during the program's execution.

  •     my_list = ["apple", "banana", "cherry"]
        print(my_list)
    
  • Tuple:

    1. Tuple is an ordered collection of elements, similar to a list.

    2. Tuples are immutable, which means you cannot modify their elements after creation.

    3. Elements in a tuple are enclosed in parentheses ( ).

    4. Tuples allow duplicate elements.

    5. Tuples are useful when you want to create a collection that should not be changed or to represent fixed data.

  •     thistuple = ("apple", "banana", "cherry")
        print(thistuple)
    
  • Set:

    1. Set is an unordered collection of unique elements.

    2. Sets are mutable, meaning you can add or remove elements after creation.

    3. Elements in a set are enclosed in curly braces { }.

    4. Sets do not allow duplicate elements; each element is unique.

    5. Sets are useful when you want to perform mathematical set operations like union, intersection, etc., or when you need to ensure uniqueness of elements in a collection.

  •     thisset = {"apple", "banana", "cherry"}
        print(thisset)
    
  1. Create below Dictionary and use Dictionary methods to print your favourite tool just by using the keys of the Dictionary.

  1. Create a List of cloud service providers eg.

If you find my blog valuable, I invite you to like, share, and join the discussion. Your feedback is immensely cherished as it fuels continuous improvement. Let's embark on this transformative DevOps adventure together! ๐Ÿš€ #devops #90daysofdevop #python

ย