1. Write a Python Numpy program to generate 10 numbers in array a then update fifth number to value 8.
The output is:
Array a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expected Answer:
Initial array: [ 1 2 3 4 5 6 7 8 9 10]
Update fifth value to 8:
[ 1 2 3 4 8 6 7 8 9 10]
Sample Answer:
import numpy as np a = np.arange(1, 11) print('Initial array:', a) print("\nUpdate fifth value to 8:") a[4] = 8 print(a)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)