Skip to main content

Command Palette

Search for a command to run...

Day 14 : Python Data Types and Data Structures for DevOps

Updated
2 min read

We will learn data types and data structures in Python on day 14. Let's start.

Python has four numeric data types: int, float, complex, and bool.

  • int: Represents integers (whole numbers) such as 1, 2, 3, etc.

  • float: Represents decimal numbers such as 1.0, 2.5, 3.14, etc.

  • complex: Represents complex numbers such as 2+3j, 3-2j, etc.

  • bool: Represents boolean values True and False.

Python has three sequence data types: list, tuple, and range.

Task 1 : Give the Difference between List, Tuple and set. Do Handson and put screenshots as per your understanding.

  1. List:

    • A list is an ordered sequence of elements enclosed in square brackets [].

    • It is mutable, which means we can change the elements after creating a list.

    • List allows duplicates.

    • We can access the elements using indexing and slicing.

    • Lists are used when we want to store an ordered collection of items.

  1. Tuple:

    • A tuple is an ordered sequence of elements enclosed in parentheses ().

    • It is immutable, which means we cannot change the elements after creating a tuple.

    • Tuple allows duplicates.

    • We can access the elements using indexing and slicing.

    • Tuples are used when we want to store a collection of items that should not be changed.

  1. Set:

    • A set is an unordered collection of unique elements enclosed in curly braces {} or set().

    • It is mutable, which means we can add or remove elements after creating a set.

    • Set does not allow duplicates.

    • We cannot access the elements using indexing and slicing.

    • Sets are used when we want to perform mathematical operations like union, intersection, difference, etc. on collections of items.

Task 2 : 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 and Write a program to add Digital Ocean to the list of cloud_providers and sort the list in alphabetical order.

That was all for Day 14 Challenge. It was easy. I hope I can clear your doubt by attaching screenshots. Looking forward to the next challenge.

happy coding

More from this blog

Ajay Patel

116 posts