Page 51 - Modular v1.1 Pyhton
P. 51

E.  Long answer type questions.

                     1.   Draw the flowchart of the for loop.
                     2.   Define the use of while statement with the help of an example and flowchart.
                     3.   Distinguish between continue and break statements.
                                                                                                 Critical Thinking
                 F.  Write the output of the following programs.

                     1.  x=1                             2.     fruits = ["apple", "banana", "cherry"]
                         sum=0                                 for x in fruits:
                         while(x<=10):                             print(x)
                             sum=sum+x
                              x=x+1
                         print (sum)
                     3.  i = 2                           4.    i = 0
                         while True:                           while i < 5:
                             if i%3 == 0:                          print(i)
                                 break                             i += 1
                             print(i)                             if i == 3:
                             i += 2                                    break
                                                               else:
                                                                  print(0)
                                                                                              Experiential Learning
                 G.   Application based question.
                     Swara 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?



                                                   In the lab                                    Inter-Disciplinary



                   Write a program to:
                   1.   determine whether a given number is an Armstrong number or not.

                   2.  to print the numbers 8, 11, 14, 17, 20, . . . .
                   3.  print 1 to 100 using while loop.
                   4.   find out the sum of numbers within the range 1 to 100 using while loop.

                   5.  calculate the sum of first ten even numbers by using while loop and for loop.
                   6.   print first 20 odd numbers in decreasing order using while loop.






                  Teacher's Corner

                 1.   Discuss about all the iterative statements of Python with the students.
                 2.   Go through all the topics covered in this chapter.





                                                                                  Looping Statements in Python    49
   46   47   48   49   50   51   52   53   54   55   56