Page 95 - KEC Khaitan C8 Flipbook
P. 95

On running the above program, we get the following output:

                     Output

                  3
                  33
                  333
                  3333




                 Program 8: To print the pattern of stars in decreasing order in the form of triangle.

                     Program8.py

                  File  Edit  Format   Run    Options   Window    Help

                  #Program to create star pattern

                  for i in range(10, 0, -1):
                      print("*"*i)




                 On running the above program, we get the following output:

                     Output

                  **********
                  *********
                  ********
                  *******
                  ******
                  *****
                  ****
                  ***
                  **
                  *





                      REVISIT



                       Iterative statements refer to the statements that are used to repeat a task based on a given condition.
                       The for loop is a type of iterative statement that allows the user to repeat a set of statements multiple times
                     until a given condition is falsified.
                       The range() function is an in-built function in Python. This function generates a sequence of numbers.
                       The while loop repeats a block of statements while a given condition is true
                       Jump statements are used to jump out of the loop iterations even if the condition has not become False.
                       The break statement is used for exiting the program control out of the loop.
                       The continue statement causes the program to skip the rest of the statement of the current block and move
                     to the next iteration of the loop.






                                                                                                Iteration in Python  93
   90   91   92   93   94   95   96   97   98   99   100