Page 309 - C++
P. 309

CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
                                      (Sub Code: 083 Paper Code 91 Outside Delhi)

                                52     42      -10    60     90     20
                                42     52      -10    60     90     20
                                42     -10     52     60     90     20
                                42     -10     52     60     90     20
                                42     -10     52     60     90     20
                                42     -10     52     60     20     90

                          II Pass
                                  42     -10    52     60     20      90
                                  -10    42     52     60     20      90
                                  -10    42     52     60     20      90
                                  -10    42     52     60     20      90
                                  -10    42     52     20     60      90

                          III Pass
                                  -10    42     52     20     60      90
                                  -10    42     52     20     60      90
                                  -10    42     52     20     60      90
                                  -10    42     20     52     60      90


                          (1 mark for last set of values of each correct pass)
                   (b)    Write definition of a method ​EvenSum(NUMBERS) to add those values in the list of                                    3
                          NUMBERS, which are odd.

                   Ans    def EvenSum(NUMBERS):
                              n=len(NUMBERS)
                              s=0
                              for i in range(n):
                                  if (i%2!=0):
                                      s=s+NUMBERS[i]
                              print(s)

                          (½ mark for finding length of the list)
                          ( ½ mark for initializing s (sum) with 0)
                          ( ½ mark for reading each element of the list using a loop)
                          ( ½ mark for checking odd location)
                          ( ½ mark for adding it to the sum)
                          ( ½ mark for printing or returning the value)
                   (c)    Write Addnew(Member) and Remove(Member) methods in python to Add a new                               4
                          Member and Remove a Member from a List of Members, considering them to act as
                          INSERT and DELETE operations of the data structure Queue.
                   Ans    class queue:
                            Member=[]
                            def Addnew(self):
                              a=input("enter member name: ")
                              queue.Member.append(a)
                            def Remove(self):
                              if (queue.Member==[]):
                                print "Queue empty"
                              else:
                                print "deleted element is: ",queue.Member[0]

                                                     Page #19 of 28
   304   305   306   307   308   309   310   311   312   313   314