Write a NumPy program to take values from a source array and put them at specified indices of another array

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

Write a NumPy program to take values from a source array and put them at specified indices of another array.

الأجوبة

import numpy as np
x = np.array([10, 10, 20, 30, 30], float)
print(x)
print("Put 0 and 40 in first and fifth position of the above array")
y = np.array([0, 40, 60], float) 
x.put([0, 4], y)
print("Array x, after putting two values:")
print(x)

Sample Output:

[ 10.  10.  20.  30.  30.]                                                             
Put 0 and 40 in first and fifth position of the above array                            
Array x after put two values:                                                          
[  0.  10.  20.  30.  40.]
هل كان المحتوى مفيد؟

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

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