Day 14: Task: Python Data Types and Data Structures for DevOps
Manish Negi
Aspiring DevOps Engineer | AWS | Linux | Bash Scripting | Docker | Git | Kubernetes | Jenkins
Data Types
To check what is the data type of the variable used, we can simply write:?your_variable=100?type(your_variable)
Data Structures
Data Structures are a way of organizing data so that it can be accessed more efficiently depending upon the situation. Data Structures are fundamentals of any programming language around which a program is built. Python helps to learn the fundamental of these data structures in a simpler way as compared to other programming languages.
Tasks
Refer above
2. Create below Dictionary and use Dictionary methods to print your favourite 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"
}
# solution
fav_tools = {
1:"Linux",
2:"Git",
3:"Docker",
4:"Kubernetes",
5:"Terraform",
6:"Ansible",
7:"Chef"
}
print(fav_tools.get(1))
3. 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.
[Hint: Use keys to built in functions for Lists]
solution
cloud_providers = ["AWS","GCP","Azure"]
print(type(cloud_providers))
cloud_providers.append("Digital Ocean")
print(cloud_providers)
cloud_providers.sort()
print(cloud_providers)