Page 359 - C++
P. 359

CBSE AISSCE 2017-2018 Marking Scheme for Computer Science
                                       (2018-2019 Sub Code: 083       Paper Code: 91)

                     (c)  Rewrite the following code in python after removing all syntax error(s). Underline                                  2
                          each correction done in the code.

                          Val = int(rawinput("Value:"))
                          Adder = 0

                          for C in range(1,Val,3)
                              Adder+=C
                              if C%2=0:
                                  Print C*10
                              Else:
                                  print C*
                          print Adder

                    Ans  Val = int(raw_input("Value:"))  # Error 1
                          Adder = 0

                          for C in range(1,Val,3)​ : ​      # Error 2
                                 Adder+=C
                                 if C%2==0:​                 # Error 3
                                        print C*10            # Error 4
                                 else:​                      # Error 5
                                        print C ​              # Error 6
                          print Adder


                          OR
                          Corrections mentioned as follows:

                              raw_input in place of rawinput
                              : to be placed in for
                              == in place of =
                              print in place of Print
                              else in place of Else
                              C* is invalid, replaced by a suitable integer or C

                          (½ Mark for each correction, not exceeding 2 Marks)
                          OR

                          (1 mark for identifying the errors, without suggesting corrections)

                     (d)  Find and write the output of the following python code:                              2
                          Data   = ["P",20,"R",10,"S",30]
                          Times  = 0
                          Alpha  = ""
                          Add    = 0
                          for C in range(1,6,2):
                              Times= Times + C



                                                        Page #17/35
   354   355   356   357   358   359   360   361   362   363   364