Q:

Write a NumPy program to construct an array by repeating. Sample array: [1, 2, 3, 4]

0

Write a NumPy program to construct an array by repeating.
Sample array: [1, 2, 3, 4]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
a = [1, 2, 3, 4]
print("Original array")
print(a)
print("Repeating 2 times")
x = np.tile(a, 2)
print(x)
print("Repeating 3 times")
x = np.tile(a, 3)
print(x)

Sample Output:

Original array                                                         
[1, 2, 3, 4]                                                           
Repeating 2 times                                                      
[1 2 3 4 1 2 3 4]                                                      
Repeating 3 times                                                      
[1 2 3 4 1 2 3 4 1 2 3 4]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now