Page 340 - Computer Science V2.0 Class 11
P. 340

xxxix.                           xxxx.                            xxxxi.


















                      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

                    Assertion(A):  Every loop must have a range() in the header.
                    Reasoning(R):  range() denotes a sequence of numbers.


                     Case-based Questions


                 1.  Sumita is teaching her younger brother about dividends and divisors. To make him practice the concept,   she wants to write
                    a program in Python that can quickly generate all divisors of a given number. Can you help her in this task?
                 2.  Nusrat has just studied Mersenne numbers. He knows that numbers in the form of 2 1 are called Mersenne numbers. For
                                                                                        n_
                    example
                     1
                            2
                    2 –1 = 1, 2 –1 = 3, 2 –1 = 7, and so on.
                                    3
                    He now wants to write a program in Python that displays the first n Mersenne numbers, where n is provided by the user at
                    execution time. Help him to do that.
                                              NCERT Exercise Solutions


                 1.  What is the difference between else and elif construct of if statement?
               Ans.
                     else                                             elif
                     else is a part of if statement.                  The elif is short for else if.
                     else statement is executed whenever the if statement   elif  executed block of  code whenever  one of  the condition
                      is getting false.                               evaluate true.
                                                                      Example:
                     Example:
                                                                      num = -5
                     a = 10
                                                                      if (num > 0):
                     b = 20
                                                                          print ("positive number")
                     if(a < b):
                                                                      elif (num == 0):
                         print ("a less than b")
                                                                          print ("zero")
                     else:
                                                                      else:
                         print ("a is not less than b")
                                                                          print ("negative number")
               326   Touchpad Computer Science (Ver. 2.0)-XI
   335   336   337   338   339   340   341   342   343   344   345