LIST (Class XI) • It is an ordered set of values enclosed in square brackets []. • Values in the list can be modified, i.e. it is mutable. • As it is set of values, we can use index in square brackets [] to identify a value belonging to it. • The values that make up a list are called its elements, and they can be of any type. . Its syntax is: Variable name [index] (variable name is name of the list). Let's look at some example of simple list: i) >>>L1 = [1, 2, 3, 4] # list of 4 integer elements. ii) >>>L2 = [“Delhi”, “Chennai”, “Mumbai”] #list of 3 string elements. iii) >>>L3 = [ ] # empty list i.e. list with no element iv) >>>L4 = [“ abc ”, 10, 20] # list with different types of elements v) >>>L5 = [1, 2, [6, 7, 8], 3] # A list containing another list known as nested list Creating and Accessing List • To create a list, put a number of expressions in square brackets. L=[] L=[value1, ...
(This blog contains full syllabus computer science of class 11 and 12 CBSE and information about python programming language)