Replace the element 'apple' in a given array with 'pear' using python code.
Array: A = ['apple', 'banana', 'orange', 'grape']
A = ['apple', 'banana', 'orange', 'grape']
A[0] = 'pear'
print(A) # Output:  ['pear', 'banana', 'orange', 'grape']