9. Write a Python Numpy program to fill in zero in left side of words with total length of 10 space including the words.
The output is:
Initial Array = ['Python', 'Numpy', 'Free', 'Exercises']
Expected Answer:
Initial Array: ['Python' 'Numpy' 'Free' 'Exercises']
String of 10 digits with zeros: ['0000Python' '00000Numpy' '000000Free' '0Exercises']
Sample Answer:
import numpy as np a = np.array(['Python', 'Numpy', 'Free', 'Exercises'], dtype=np.str) print("Initial Array:", a) b = np.char.zfill(a, 10) print("\nString of 10 digits with zeros:", b)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)