Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 149 - 2632_CodeMind
P. 149

    Program 8: To demonstrate the use of the continue statement in a loop.

                          Program8.py
                       File  Edit  Format   Run    Options   Window    Help

                       #Program to show the use of the continue statement
                       for number in range(0, 12):
                           if(number == 8):
                               continue
                           print('Number is:', number)
                       print('Out of loop')

                      You will get the following output:

                          Output

                       Number is: 0
                       Number is: 1
                       Number is: 2
                       Number is: 3
                       Number is: 4
                       Number is: 5
                       Number is: 6
                       Number is: 7
                       Number is: 9
                       Number is: 10
                       Number is: 11
                       Out of loop

                                                                                                     21 st
                       Let’s PraCtiCe                                                              Century   #Critical Thinking
                                                                                                    Skills
                         Write a program to print the even numbers between 1 and 25 by using the continue statement.

                             SOME MORE PROGRAMS

                       Program 9: To create a number pattern using for loop.

                          Program9.py
                       File  Edit  Format   Run    Options   Window    Help

                       #Program to create number pattern using for loop
                       for i in range(1,10):
                           print('3' * i)

                      148   Premium Edition-VIII

| 144 145 146 147 148 149 150 151 152 153 154 |