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

I.         if num < 0:
                                       print(num, " is a negative number")
                                   if num > 0:
                                       print(num, " is a positive number")
                                   else:
                                       print(num, " is zero")


                        II.        if num < 0:
                                       print(num, " is a negative number")
                                       if num > 0:
                                           print(num, " is a positive number")
                                   else:
                                       print(num, " is zero")


                        III.      if num < 0:

                                  if num < 0:
                                      print(num, " is a negative number")
                                      if num > 0:
                                          print(num, " is a positive number")
                                  else:
                                          print(num, " is zero")

                      a.  II only               b. II and III         c. I only              d. I, II, and III
                    9.  What will be the output produced on execution of the following code?
                      num = 3
                      if (num > 2):
                          num = num * 2
                      if (num > 4):
                          num = 0
                      print(num)
                      a.  3                     b. 0                  c. 6                   d. Error

                   10.  What will be the output produced on the execution of the following code?
                      mass = 0.5
                      itemCount = 10
                      if mass < 2:
                          amount = 1.45
                      if mass >= 2:
                          amount = 1.2
                      total = mass * amount
                      if itemCount > 10:
                          total = total * 0.7
                      print(total)
                      a.  0.725                 b. 0.5075             c. 0.6                 d. 0.42





                                                                                               Conditional Statements  271
   280   281   282   283   284   285   286   287   288   289   290