Find the output of following program: import numpy as np d=np.array([10,20,30,40,50,60,70])
print(d[-4:])
Answers
Answered by
3
Answer:10,20,30,40
Explanation:
Answered by
9
The output of the above program are: 40,50,60,70.
Explanation:
- The first line of the above program creates an np object of 'numpy array'.
- The second line of the above program is to create an integer array of variable d and store the value on it.
- The third line prints the value of the 3rd index to the last index.
It is because, if (:) is placed with an array index then the value is printed with the given index to the last index. for example, if the print statement holds 3: then it will print the value from the third index of the array to the last index of the array. so the 4: prints the value from the fourth index of the array to the last index but in the above code, the print statement holds (-4:) which means (3:) that's why it prints 40 to 70, where 40 is the third index value of the array.
Learn More:
- Complete the following program and find the output? https://brainly.in/question/11912937
- Find the output of the program segments https://brainly.in/question/10679270
Similar questions
Political Science,
6 months ago
Hindi,
6 months ago
Social Sciences,
6 months ago
Math,
1 year ago
Science,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago