Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 124 - 2620_Birla Open Mind C-8
P. 124

    E.     Brain Boost.                                                       Century   #Critical Thinking
                                                                                              21 st
                                                                                              Skills
                          1.  Write the output of the following programs:
                             a.  x=1
                                 sum=0

                                 while(x<=10):
                                     sum=sum+x
                                     x=x+1
                                 print (sum)
                             b.   start = 1

                                 end = 10
                                 for number in range(start, end + 1):
                                     square = number ** 2
                                     print("The square of", number, "is", square)
                             c.  i = 2

                                 while True:
                                     if i%3 == 0:
                                         break

                                     print(i)
                                     i += 2
                             d.  i = 0

                                 while i < 5:
                                     print(i)

                                     i += 1
                                     if i == 3:
                                         break
                                     else:
                                         print(0)
                             e.  numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                                    for number in numbers:

                                      if number % 2 == 0:
                                         print(number, "is even")
                                     else:
                                         print(number, "is odd")
                          2.  Competency-based/Application-based questions:

                             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.   Your brother Atharv wants to write a statement which will cause the program to skip the rest of
                                the statement of the current block and to move to the next iteration of the loop. But he is unable
                                to do it. Suggest the statement he should use for this.

                      122  Premium Edition-VIII

| 119 120 121 122 123 124 125 126 127 128 129 |