4. Write a Python Numpy program to calculate the division of a list of number with number 2 then obtain the remainder of the division.
The output is:
Initial array = [1, 2, 3, 4, 5]
Expected Answer:
Initial array: [1 2 3 4 5]
The remainder of division 2: [1 0 1 0 1]
Sample Answer:
import numpy as np a = np.arange(1, 6) print("Initial array:", a) print("\nThe remainder of division 2 is", np.remainder(x, 2))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)