Write a NumPy program to create an array using generator function that generates 15 integers.
import numpy as np def generate(): for n in range(15): yield n nums = np.fromiter(generate(),dtype=float,count=-1) print("New array:") print(nums)
Sample Output:
New array: [ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output: