Page 206 - Information_Practice_Fliipbook_Class11
P. 206

5.  Write a program that accepts a list of numbers from a user and replaces the elements at indices which are multiples of 3, by
              the cube of the number at that index. Elements at other indexes should remain unchanged. For example, if the user enters
              the list:
              [3, 5, 5, 2, 8, 9, 7, 21, 6, 5, 4]
              the program should display the list:

              [27, 5, 5, 8, 8, 9, 343, 21, 6, 125, 4]
              You should not create a new list, but rather modify the existing list.
           6.  Write a program that takes a list as input (say, key) and searches for a key in the list. If the key is found in the list the
              program should output the index of the first occurrence in the list, otherwise, the program should print an appropriate
              message.
           7.  Write a program that takes a list as input (say, key) and searches for a key in the list. If the key is found in the list the
              program should output the index of the last occurrence in the list, otherwise, the program should print an appropriate
              message.
           8.  Write a program that takes a list as input (say, key) and searches for a key in the list. If the key is found in the list the
              program should output the index of the first occurrence in the list, otherwise, the program should print an appropriate
              message. The index returned should be a negative number.
           9.  Write a program that takes a list as input (say, key) and searches for a key in the list. If the key is found in the list the
              program should output the index of the last occurrence in the list, otherwise, the program should print an appropriate
              message. The index returned should be a negative number.
          10.  Write a program that accepts a list of lists RollNoMarksList (each inner list comprises a pair of roll numbers and marks
              of  students) from the user and the RollNo and outputs the updated list with the marks increased by 5 corresponding to
              RollNo.
          11.  Write a program that accepts a list of lists NameMarksList (where each inner list comprises a pair of roll number
              and marks of students) and outputs the updated list with the marks appropriately moderated according to the following
              criteria:

                                          Marks range                         moderation

                              marks < 40                                          6
                              40<=marks<50                                        5
                              50<=marks<60                                        4
                              60<=marks<70                                        3
                              70<=marks<80                                        2
                              80<=marks<90                                        1
                              90<=marks                                           0



                Assertion and Reasoning Based Questions


           The following questions are assertion(A) and reasoning(R) based. Mark the correct choice as
           a.  Both A and R are true and R is the correct explanation of A
           b.  Both A and R are true and R is not the correct explanation of A
           c.  A is true but R is false
           d.  A is false but R is true

           1.  Assertion(A):  Elements of a list can be accessed using indexes.
              Reasoning (R):  The list is a sequence data type, and the elements of a sequence data type can be accessed using indexes.

           2.  Assertion(A):  The function call sorted(lst) yields a list sorted in ascending order.
              Reasoning(R):  The list is a mutable data type.



          192  Touchpad Informatics Practices-XI
   201   202   203   204   205   206   207   208   209   210   211