मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता १२

What is a List? Why List can be called as Pairs. Explain with a suitable example? - Computer Science

Advertisements
Advertisements

प्रश्न

What is a List? Why List can be called as Pairs. Explain with a suitable example?

थोडक्यात उत्तर

उत्तर

The list is constructed by placing expressions within square brackets separated by commas. Example for List is [10, 20],
The elements of a list can be accessed in two ways. The first way is via our familiar method of multiple assignments, which unpacks a list into its elements and binds each element to a different name.
1st: = [10, 20]
x, y: = 1st
In the above example, x will become 10 and y will become 20.
A second method for accessing the elements in a list is by the element selection operator, also expressed using square brackets. Unlike a list literal, a square – brackets expression directly following another expression does not evaluate a list value but instead selects an element from the value of the preceding expression.
1st [0]
10
1st [1]
20
In both the example mentioned above mathematically we can represent a list similar to a set.
1st [(0, 10), (1, 20)] – where

Any way of bundling two values together into one can be considered as a pair. Lists are a common method to do so. Therefore List can be called a pair.

shaalaa.com
Lists, Tuples
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 2: Data Abstraction - Evaluation [पृष्ठ २०]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 12 TN Board
पाठ 2 Data Abstraction
Evaluation | Q 2. | पृष्ठ २०
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×