Write a NumPy program to create a new array of 3*5, filled with 2

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

Write a NumPy program to create a new array of 3*5, filled with 2

الأجوبة

import numpy as np
#using no.full
x = np.full((3, 5), 2, dtype=np.uint)
print(x)
#using no.ones
y = np.ones([3, 5], dtype=np.uint) *2
print(y)

Sample Output:

[[2 2 2 2 2]                                                           
 [2 2 2 2 2]                                                           
 [2 2 2 2 2]]                                                          
[[2 2 2 2 2]                                                           
 [2 2 2 2 2]                                                           
 [2 2 2 2 2]]
هل كان المحتوى مفيد؟

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

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