Python - Basics
So moving forward with my #90daysofdevops Day 13 and Day 14 challenge today I have learned the basics of Python and brushed up some concepts that are required.
The different data structures in Python are,
String | List | Tuple | Set | Dictionary | |
Type | Immutable | Mutable | Immutable | Mutable | Mutable |
Syntax | "text" | [item1, item2, ..., itemN] | (item1, item2, ..., itemN) | {item1, item2, ..., itemN} | {key1: value1, key2: value2, ...} |
Indexing | Access via index (0-based) | Access via index (0-based) | Access via index (0-based) | No indexing | Access via key |
Ordering | Ordered | Ordered | Ordered | Unordered | Unordered |
Duplicates | Duplicates allowed | Duplicates allowed | Duplicates allowed | No duplicates allowed | Duplicates allowed |
Modification | Immutable (Cannot change individual characters) | Mutable (Can add, remove, and modify elements) | Immutable (Cannot change individual elements) | Mutable (Can add and remove elements, but cannot modify) | Mutable (Can add, remove, and modify key-value pairs) |
Example | "Hello, World!" | [1, 2, 3, 4] | (1, 2, 3, 4) | {1, 2, 3, 4} | {"name": "John", "age": 30, "city": "New York"} |
Note: The table provides a general overview of the differences between these data structures, but there might be additional details and functionalities for each that are not mentioned here.
Here are some of the basic tasks I have completed using python
- Create the below Dictionary and use Dictionary methods to print your favorite tool just by using the keys of the Dictionary.
fav_tools =
{
1:"Linux",
2:"Git",
3:"Docker",
4:"Kubernetes",
5:"Terraform",
6:"Ansible",
7:"Chef"
}
- Create a List of cloud service providers eg.
cloud_providers = ["AWS","GCP","Azure"]
Write a program to add Digital Ocean
to the list of cloud_providers and sort the list in alphabetical order.
I am grateful for the valuable knowledge gained during this journey, and I look forward to diving deeper into Python! Stay tuned for more exciting updates! ๐๐
#DevOps #Git #GitHub #VersionControl #CodingJourney #LearningInProgress #python