Posts

Showing posts from October, 2025

Python Programming - Lists, Tuples, Dictionaries (UNIT – Iv)

  UNIT – Iv Python Programming - Lists, Tuples, Dictionaries 1. Creating a List Definition: A list is an ordered, mutable (changeable) collection of elements in Python. Lists can store different data types — integers, strings, floats, or even other lists. Syntax: list_name = [element1, element2, element3, ...] Example: numbers = [10, 20, 30, 40] names = ["Murugan", "Shanmugam", "Karthikeyan"] mixed = [1, "apple", 3.5, True] Using the list() constructor: data = list((1, 2, 3, 4)) Important Points: Lists are indexed starting from 0. Lists are mutable , meaning elements can be changed after creation. 2. Accessing Values in a List Indexing: Each element in a list has a position number (index). Positive indexing starts from 0. Negative indexing starts from -1 (last element). Example: fruits = ["apple", "banana", "cherry", ...