Write the output?import numpy as np a = np.array( [1 ,2 , 3])b = np.append(a , [4, 5, 6])print( b, len(b) )
Question
Write the output?
import numpy as np
a = np.array([1, 2, 3])
b = np.append(a, [4, 5, 6])
print(b, len(b))
Solution
The output of the given Python code will be:
[1 2 3 4 5 6] 6
Here's the step by step explanation:
- First, the numpy module is imported as np.
- Then, a numpy array 'a' is created with elements 1, 2, and 3.
- The np.append() function is used to append the elements 4, 5, and 6 to the array 'a'. The result is stored in the array 'b'.
- Finally, the print statement prints the array 'b' and the length of 'b' which is 6.
Similar Questions
l = [1,2,3,4,5,6]l.append([a,b,c,d,e,f,g,h,i,j,k])print(len(l))What will be the output of this code in python
What will the output of the following code be?l = [32, 34, 12, 27, 33]l.append([14, 19])print(len(l))
Output of the below snippet: import numpy as np a=np.array([100,2,300,]) print(a[0],a[2])
What will be the output of the following Python code?A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B = [[3, 3, 3], [4, 4, 4], [5, 5, 5]] zip(A, B)
What is the output of below code snippeta = [ [8, 2] , [4, 1, 2, 2] ]b = a[1][2:]print(b)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.