Write a NumPy program to find the union of two arrays. Union will return the unique, sorted array of values that are in either of the two input arrays

  • برمجة بايثون

Write a NumPy program to find the union of two arrays. Union will return the unique, sorted array of values that are in either of the two input arrays

الأجوبة

import numpy as np
array1 = np.array([0, 10, 20, 40, 60, 80])
print("Array1: ",array1)
array2 = [10, 30, 40, 50, 70]
print("Array2: ",array2)
print("Unique sorted array of values that are in either of the two input arrays:")
print(np.union1d(array1, array2))

Sample Output:

Array1:  [ 0 10 20 40 60 80]                                           
Array2:  [10, 30, 40, 50, 70]                                          
Unique sorted array of values that are in either of the two input array
s:                                                                     
[ 0 10 20 30 40 50 60 70 80]
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...