Title: "Updating Elements in Arrays in Python "
Subtitle: "Modifying Values at Specific Indices"
Name Section: Mahesh Tolanur (32)
Darshan Dhumal (14)
Shahid Desai (45)
Aditya Takkekar (5)
What is Updating in Arrays ?
• "Updating involves modifying the value at a specific index
in the array."
• The process of updating (modifying/changing) an existing
element of an array at a specified index with another
element is called updating an array or update operation in
array.
• Essential for dynamically changing data within an array."
Example
# Creating an array
my_array = [10, 20, 30, 40, 50]
# Displaying the original array
print("Original Array:", my_array)
Output-[10,20,30,40,50]
# Updating the element at index 2
my_array[2] = 35
# Displaying the updated array
print("Updated Array:", my_array)
Output- [10,20,35,40,50]
Here are Few examples for Practices
# Example 1
array1 = [5, 10, 15]
array1[1] = 20
print("Example 1:", array1)
# Example 2
array2 = ['apple', 'banana', 'cherry']
array2[0] = 'orange'
print("Example 2:", array2)
# Example 3
array3 = [100, 200, 300, 400, 500]
array3[3] = 450
print("Example 3:", array3)
# Example 4
array4 = ['a', 'b', 'c', 'd']
array4[2] = 'x'
print("Example 4:", array4)
Real-Life Use Cases"
Database Management:
• Use Case: Updating Customer Information
Inventory Tracking:
• Use Case: Updating Product Quantities
Gaming Application:
• Use Case: Updating Player Scores
Financial Analytics:
• Use Case: Updating Stock Prices