📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 138question

LISTS, TUPLES, SETS AND DICTIONARY · Part 2

Chapter 3: 4 · COMPUTER SCIENCE

the beginning index value of a list. Marks = [ , , , ] i = while i < : print (Marks[i]) i = i + Output Example In the above example, Marks list contains four integer elements i.e., , , , . Each element has an index value from . The index value of the elements are , , , respectively.

Here, the while loop is used to read all the elements. The initial value of the loop is zero, and the test condition is i < , as long as the test condition is true, the loop executes and prints the corresponding output. 12th Computer Chapter - - Lists, Tuples, Sets and Dictionary During the first iteration, the value of i is , where the condition is true. Now, the following statement print (Marks [i]) gets executed and prints the value of Marks [ ] element ie.

. The next statement i = i + increments the value of i from to . Now, the flow of control shifts to the while statement for checking the test condition. The process repeats to print the remaining elements of Marks list until the test condition of while loop becomes false.

The following table shows that the execution of loop and the value to be print. Iteration i while i < print (Marks[i]) i = i + < True Marks [ ] = + = < True Marks [ ] = + = < True Marks [ ] = + = < True Marks [ ] = + = < False -- -- (ii) Reverse Indexing Python enables reverse or negative indexing for the list elements. Thus, python lists index in opposite order. The python sets - as the index value for the last element in list and - for the preceding element and

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →