More about Python..

More about Python..

Data Types

In Python, data types are a classification system for various types of data that can be used in programming. Python has several built-in data types, and they are used to define and work with different kinds of data. Here are the most common data types in Python:

  1. Numeric Types:

    • int: Represents integers, e.g., 42, -10.

    • float: Represents floating-point numbers, e.g., 3.14, 2.0.

    • complex: Represents complex numbers, e.g., 3 + 2j.

  2. Boolean Type:

    • bool: Represents boolean values, either True or False.
  3. Text Type:

    • str: Represents strings of characters, e.g., "Hello, World!", 'Python'.
  4. Sequence Types:

    • list: Represents ordered, mutable (changeable) sequences, e.g., [1, 2, 3].

    • tuple: Represents ordered, immutable (unchangeable) sequences, e.g., (4, 5, 6).

    • range: Represents a sequence of numbers, often used in loops and iterations.

  5. Mapping Type:

    • dict: Represents key-value pairs, e.g., {"name": "Alice", "age": 30}.
  6. Set Types:

    • set: Represents an unordered collection of unique elements, e.g., {1, 2, 3}.

    • frozenset: Represents an immutable set.

  7. None Type:

    • None: Represents a special null value or absence of a value.
  8. Binary Types:

    • bytes: Represents a sequence of bytes, e.g., b'hello'.

    • bytearray: Represents a mutable sequence of bytes.

    • memoryview: Represents a memory view object.

Data Structure

data structures are containers or objects that are used to store and organize data efficiently. Python offers several built-in data structures to work with different types of data and solve various computational problems. Here are some of the most commonly used data structures in Python:

  1. Lists:

    • A list is an ordered, mutable collection of items. Lists can contain elements of different data types, and you can add, remove, and modify elements as needed.

Example:

    pythonCopy codemy_list = [1, 2, 'hello', 3.14]
  1. Tuples:

    • A tuple is an ordered, immutable collection of items. Once you create a tuple, you cannot change its contents.

Example:

    pythonCopy codemy_tuple = (1, 2, 'world', 2.71)
  1. Dictionaries:

    • A dictionary is an unordered collection of key-value pairs. It is used for storing data in a way that allows for efficient lookups and retrieval based on keys.

Example:

    pythonCopy codemy_dict = {'name': 'Alice', 'age': 30, 'city': 'New York'}
  1. Sets:

    • A set is an unordered collection of unique elements. It is used when you want to store a collection of distinct values.

Example:

    pythonCopy codemy_set = {1, 2, 3, 4, 5}
  1. Strings:

    • A string is a sequence of characters. While not a traditional data structure, strings are used to store and manipulate text data.

Example:

    pythonCopy codemy_string = "Hello, Python"
  1. Arrays (from the array module):

    • An array is a more efficient data structure for storing sequences of items of the same type. It is part of the Python's standard library and offers features similar to lists.

Example:

    pythonCopy codefrom array import array
    my_array = array('i', [1, 2, 3, 4, 5])
  1. Queues and Stacks:

    • Python provides various modules, like queue and collections.deque, for implementing queues and stacks, which are used for managing data in a first-in-first-out (FIFO) or last-in-first-out (LIFO) manner.

Today Task:-

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

  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"
}
  1. Create a List of cloud service providers eg.
cloud_providers = ["AWS","GCP","Azure"]

Day 14 of #90daysofDevOps

Thanks for reading

Follow me for more about DevOps♾️........

________________________________________________________________________________

#90daysHardChallenge

#Cloudcomputing

#DevOps

#Python

#TrainWithShubham