Create a 2-dimensional array of size 2 x 3, composed of 4-byte integer elements. Write a NumPy program to find the number of occurrences of a sequence in the said array
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
np_array = np.array([[1, 2, 3], [2, 1, 2]], np.int32)
print("Original Numpy array:")
print(np_array)
print("Type: ",type(np_array))
print("Sequence: 1,2",)
result = repr(np_array).count("1, 2")
print("Number of occurrences of the said sequence:",result)
Sample Output:
Original Numpy array: [[1 2 3] [2 1 2]] Type: <class 'numpy.ndarray'> Sequence: 1,2 Number of occurrences of the said sequence: 2
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال