Page 345 - AI Ver 1.0 Class 9
P. 345

S. No                           Questions                                      Answers
                 38    To insert 10 to the fourth position in L1, we use:          b

                       a) L1.insert(10, 4)
                       b) L1.insert(4, 10)

                       c) L1.extent(10,4)
                       d) L1.append(10,4)

                 39    What will be the output of the following code?
                       L1=[1,2,3,4,5]                                              a
                       print(L1.index(2))

                       a) 1       b) 2       c) 3       d) False
                 40    What will be the output of the following code?              [1, 2, 3, 3, 4, 5, 5, 6, 7]
                       L1=[1,2,3,4,5]

                       L2=[6,7]
                       L1.append(5)

                       L1.extend(L2)
                       L1.insert(2,3)

                       print(L1)
                 41    What will be the output of the following code?              [6,7,8]
                       m=[]

                       for i in [6,7,8]:
                         m.append(i)

                       print(m)
                 42    What will be the output of the following code?              [4, 5, 6, 1, 2, 3]

                       Rollno=[1,2,3,4,5,6]
                       x=int(len(Rollno)/2)

                       for i in range(x):
                       Rollno[i],Rollno[x+i]=Rollno[x+i],Rollno[i]
                       print(Rollno)

                 43    What will be the output of the following code?              [10, 20, 40]
                       L1=[10,20,30]

                       L2=[40,50]
                       L1.remove(30)
                       L1.extend(L2)

                       L1.pop()
                       print(L1)




                                                                             Python Practical Questions  343
   340   341   342   343   344   345   346   347   348   349   350