DEV Community

Cover image for Day 46 of My Data Analytics Journey !
Ramya .C
Ramya .C

Posted on

Day 46 of My Data Analytics Journey !

Today I focused on strengthening my Python fundamentals, which are essential for building a solid base in data analytics and problem-solving.

🔹 Topics I Explored

1️⃣ List

  • Definition: A list is a collection of ordered and mutable elements in Python.
  • Example:
  fruits = ["apple", "banana", "cherry"]
  print(fruits)
Enter fullscreen mode Exit fullscreen mode

2️⃣ Tuple

  • Definition: A tuple is a collection of ordered and immutable elements.
  • Example:
  colors = ("red", "green", "blue")
  print(colors)
Enter fullscreen mode Exit fullscreen mode

3️⃣ Dictionary

  • Definition: A dictionary stores key–value pairs and is mutable.
  • Example (Student Details Program):
  # Create Dictionary
  students = {
      1: {"name": "Ramya", "age": 21},
      2: {"name": "Visky", "age": 22}
  }

  # Add
  students[3] = {"name": "Maha", "age": 23}

  # Update
  students[2]["age"] = 23

  # Delete
  del students[1]

  # View
  print(students)
Enter fullscreen mode Exit fullscreen mode

🔹 Additional Concepts Learned

4️⃣ Homogeneous vs Heterogeneous

  • Homogeneous: All elements are of the same data type. Example: [1, 2, 3, 4]
  • Heterogeneous: Elements are of different data types. Example: [1, "Ramya", 3.5, True]

5️⃣ Ternary Operator

  • Definition: A shorthand way of writing an if-else condition in one line.
  • Example:
  age = 18
  result = "Adult" if age >= 18 else "Minor"
  print(result)
Enter fullscreen mode Exit fullscreen mode

6️⃣ Recursion

  • Definition: A function calling itself to solve a smaller version of the same problem.
  • Example (Factorial Program):
  def factorial(n):
      if n == 0:
          return 1
      else:
          return n * factorial(n - 1)

  print("Factorial of 5:", factorial(5))
Enter fullscreen mode Exit fullscreen mode

7️⃣ Stack

  • Definition: A LIFO (Last In First Out) data structure.
  • Example:
  stack = []
  stack.append(10)
  stack.append(20)
  stack.pop()
  print(stack)
Enter fullscreen mode Exit fullscreen mode

8️⃣ Queue

  • Definition: A FIFO (First In First Out) data structure.
  • Example:
  from collections import deque

  queue = deque()
  queue.append(10)
  queue.append(20)
  queue.popleft()
  print(queue)
Enter fullscreen mode Exit fullscreen mode

🔹 Bonus Practice — Sum of First 5 Natural Numbers Using Recursion


def sum_natural(n):
    if n == 0:
        return 0
    else:
        return n + sum_natural(n - 1)

print("Sum of first 5 natural numbers:", sum_natural(5))
Enter fullscreen mode Exit fullscreen mode

💬 Reflection

Today’s learning helped me deeply understand data structures, control flow, and recursion logic, which form the backbone of Python programming and data analysis.


🔖 **#Day46 #DataAnalytics #Python #LearningJourney #DevCommunity

Top comments (0)