Write a NumPy program to convert a list and tuple into arrays
- برمجة بايثون
- 2021-09-11
- mhanasmh00489829403
الأجوبة
import numpy as np
my_list = [1, 2, 3, 4, 5, 6, 7, 8]
print("List to array: ")
print(np.asarray(my_list))
my_tuple = ([8, 4, 6], [1, 2, 3])
print("Tuple to array: ")
print(np.asarray(my_tuple))
Sample Output:
List to array: [1 2 3 4 5 6 7 8] Tuple to array: [[8 4 6] [1 2 3]]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
