Posts

Showing posts with the label List Operations

Topic 12: What is List in python?

Data Type " List " in Python In Python, a List is one of the most commonly used and versatile data types. It allows us to store multiple items in a single variable. Lists are ordered, mutable (changeable), and allow duplicate values  making them perfect for storing collections of data such as numbers, strings , or even other lists. A List in Python is defined as a sequence of items enclosed in square brackets [ ] , separated by commas. Syntax: list_name = [item1, item2, item3, ...] Example: fruits = ["apple", "banana", "cherry"] numbers = [10, 20, 30, 40, 50] mixed = [10, "hello", 3.14, True] Characteristics of Python Lists Property Description Ordered The items have a defined order and can be accessed using an index. Mutable You can change, add, or remove items after creation. Heterogeneous A list can store elements of different data types. Allows Duplicates Lists can contain repeated elements. Dyna...