Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 81 - 2607_Traclpad_Pro_5.1_flipbook_C8
P. 81

    b. num = 24894

                          count = 0
                          while num != 0:
                              num //= 10
                              count += 1
                          print("Total digits are : ", count)
                         c. x=1

                          sum=0
                          while(x<=10):
                              sum=sum+x
                              x=x+1
                          print (sum)

                         d. i = 2

                          while True:
                              if i%3 == 0:
                                  break
                              print(i)
                              i += 2
                         e. i = 0

                          while i < 5:
                              print(i)
                              i += 1
                              if i == 3:
                                  break
                         f.  i = 0

                          while i < 4:
                              print (i)
                              i += 1

                      6.  Competency-based/Application-based questions.                                  Experiential Learning

                         a.   Aahana wants to repeat a block of statements for a given number of times, until the control condition
                            is false. Which type of construct can she use for this? Write its syntax.
                            ______________________________________________________________________________________
                         b.   Sohan wants to create a program in which he needs to exit a loop, when the specified condition
                            evaluates to True. But he does not know which statement is suitable for this. Help him by giving the
                            correct statement.
                            ______________________________________________________________________________________

                         c.   Manvi wants to write a statement which will cause the program to skip the rest of the statements in the
                            current block and to move to the next iteration of the loop. Which statement should she use for this?
                            ______________________________________________________________________________________

                       80   Premium Edition-VIII

| 76 77 78 79 80 81 82 83 84 85 86 |