Computer Science, asked by parmarvedeyi, 11 months ago

(e) If we have a list X [1, 2, 3, 4] how do we print the first element?
(i) Printx[0]
(ii) Printx[1]
(iii) Print first [ ]
(iv) Printx.first [ ]​

Answers

Answered by somaya95
5

Answer:

Option (iii)

Mark a Brainlist please.......plzzzzzzzzzzzz

Answered by anvitanvar032
0

Answer:

The correct answer to this question is Print first [ ]

Explanation:

Given - A list X [1, 2, 3, 4]

To Find - Choose the correct option.

If we have a list X [1, 2, 3, 4] which is  Print first [ ]  the first element.

Use the slicing syntax [] and pass a 0:n as parameters to access the first n members of a list. The start index is 0. (it is included). Another approach that makes use of the colon slicing technique to directly refer to element places is list slicing. Use a blank value before the first colon to access the first element, then use len() with -1 as the input to access the last element.

To receive the initial element instead, you may alternatively use the reset() method. The reset() method returns the value of the first array element after setting the internal pointer of the array to its first element.

#SPJ2

Similar questions