Computer Science, asked by hajera4103, 1 year ago

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 krsanj
3

Answer:10,20,30,40

Explanation:

Answered by AskewTronics
9

The output of the above program are: 40,50,60,70.

Explanation:

  1. The first line of the above program creates an np object of 'numpy array'.
  2. The second line of the above program is to create an integer array of variable d and store the value on it.
  3. 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