Arrays

  Arrays


An array is a collection of elements of the same type that are stored in contiguous memory locations. The elements can be accessed by their index position in the array.


python


# Create an array

arr = [1, 2, 3, 4, 5]


# Access an element in the array

print(arr[0]) # Output: 1


# Add an element to the array

arr.append(6)


# Remove an element from the array

arr.pop()

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...