Table of contents
In my yesterday's blog, we had a brief introduction to the datatypes in Python. If you want to follow my yesterday's blog- https://bandandevopsjourney.hashnode.dev/devopsday-13-introducing-python
Today, Let's summarize the points with some hands-on tasks.
Data Types
Data types are the grouping or categorizing of values that are passed to a program or code for executing and providing desired output.
Python has the following data types built-in by default: Numeric(Integer, complex, float), Sequential(string, lists, tuples), Boolean, Set, and Dictionaries.
To check the data type of any value passed to a variable you can use the below command.
\>>type(variable)
Data Structures
Data structures are an improvised way of organizing data that can be accessed efficiently to handle any situation.
It consists of following types:-
Lists.
Tuples.
Dictionary.
Let's see the difference between the above data structures in the tasks below.
Tasks
Give the Difference between List, Tuple and Set. Do Handson and put screenshots as per your understanding.
Create the 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" }
Answer is as below:-
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.
Thanks for reading my article.
Have a nice day.