Day 14 - Python Data Types & Structures Exploration πŸπŸ”

Day 14 - Python Data Types & Structures Exploration πŸπŸ”

Β·

2 min read

Greetings DevOps enthusiasts! Today on our journey, let's dive into the Python world of Data Types and Structures. πŸŒπŸ’‘

Data Types in Python: πŸ“ŠπŸ”’

In Python, data types classify items and determine the operations we can perform on them. Whether it's Numeric, Sequential, Boolean, or others, Python's got it all! πŸ”’πŸ“Š

In Python, data types classify the type of values that variables can hold. Let's explore a few:

  1. Numeric Types:

    • Integer (int): Whole numbers without decimals. Example: age = 25

    • Float (float): Numbers with decimals. Example: price = 19.99

    • Complex (complex): Numbers in the form a + bj, where a and b are floats. Example: z = 3 + 5j

  2. Sequential Types:

    • String (str): Ordered sequences of characters. Example: name = "John"

    • List (list): Ordered, mutable collections. Example: fruits = ["apple", "banana", "orange"]

    • Tuple (tuple): Ordered, immutable collections. Example: coordinates = (10, 20)

  3. Boolean Type:

    • Boolean (bool): Represents True or False. Example: is_devops = True
  4. Set Type:

    • Set (set): Unordered collections of unique elements. Example: unique_numbers = {1, 2, 3, 4}
  5. Dictionary Type:

    • Dictionary (dict): Unordered key-value pairs. Example: student = {"name": "Alice", "age": 21}

Data Structures in Python: πŸ¦Έβ€β™‚οΈπŸ¦Έβ€β™€οΈ

Think of these as the organizational superheroes of data. Lists, Tuples, and Dictionaries play key roles. Lists are flexible arrays, Tuples are immutable collections, and Dictionaries are optimized key-value pairs. πŸ¦Έβ€β™‚οΈπŸ¦Έβ€β™€οΈ

Data structures organize and store data efficiently. Let's look at a few:

  1. List: πŸ“œ

    • Ordered, mutable collection.

    • Example: languages = ["Python", "JavaScript", "Java"]

  2. Tuple: πŸ“¦

    • Ordered, immutable collection.

    • Example: dimensions = (10, 20, 15)

  3. Dictionary: πŸ“š

    • Unordered key-value pairs.

    • Example: book = {"title": "Python Crash Course", "author": "Eric Matthes"}

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!

Β