Showing posts with label List creation class 11 cbse. Show all posts
Showing posts with label List creation class 11 cbse. Show all posts

Saturday, 16 March 2019

List creation class 11 cbse

LIST CREATION

  • List is sequence which can store value of and kind.

CREATION OF LIST

  • >>>Mylist = list('hello')
          >>>Mylist 
                 ['h','e','l','l,'o']
  • >>>L1= list(input("enter list element"))
          Enter list Element 1,2,3,4,5
          >>> L1
          (1,2,3,4,5)
eval( ) function identifier type of passed string and then return it.

>>>a="15"
>>>b="25"
>>>print(a+b)
       1525
>>>print(eval(a)+eval(b))
       40

Accessing of list

  • len( ) function is used to get the length of list.
  • L[i] will return the value exist at index.
  • L[i:j] will return a new list with the values from i index to j list excluding j index.

Transverse of list

Transverse of a list means to access and process each and every element of that list.

List slicing

  • To slice a list index is-
>>>lst = [10,12,14,20,22,24,30,32,34]
>>> SEQ= lst[3:-3]
>>>SEQ
      [20,22,24]

SEQ=list[start:stop]
seq=list[start:stop:step]