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
Write the output? A = [1,2,3] B = [4,5] A.append(B) print(len(A))
what is the output of the following code?b = [1, 2, 3]for a in b: b.append(a)print(b)
What will the output of the following code be?l = [32, 34, 12, 27, 33]l.append([14, 19])print(len(l))
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 be the output of the below code?list1 = [1, 2, 3]list1.append([4, 5, 6])print(len(list1))Select one:3456
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.