What is an Array?

An array is one of the simplest and most commonly used data structures in programming. It stores a list of items in a specific order, and each item can be quickly accessed using its position (called an index). When you’re starting out in programming, one of the first data structures you’ll meet is the array. It’s simple, powerful, and used everywhere — from managing scores in a game to storing user data in a web app. But what exactly is an array? An array is a collection of elements stored at contiguous memory locations. Think of it as a row of lockers, where each locker (position) holds one item (value), and every locker has a number (index) that helps you find what’s inside.
  • All elements are of the same data type
  • You can access any element instantly using its index
  • Arrays are fixed in size (in most languages)
Few examples of Arrays are a music app playlist stores songs in a specific order, Items in shopping cart.

Fruits Array

Let’s say you want to store a list of your favorite fruits in a program. You can use an array to keep them organized and easily accessible.
fruits = ["apple", "banana", "mango", "orange"]

print( fruits[0] )  # Output: apple
print( fruits[2] )  # Output: mango
In this example, the array fruits holds four string values. Each fruit is stored at a specific index:
  • fruits[0] is "apple"
  • fruits[1] is "banana"
  • fruits[2] is "mango"
  • fruits[3] is "orange"
An array stores elements in a specific order, and each item can be accessed using its index — starting from 0. In the fruits array, if you want the third fruit, you simply use fruits[2]. This makes arrays ideal for situations where you need to organize and retrieve items quickly using their position in a list. Arrays are efficient, easy to use, and form the backbone of many other data structures. https://en.wikipedia.org/wiki/Array _(data_structure)