Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 91 - 2615_KEC
P. 91

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

                         Program15.py

                      File  Edit  Format   Run    Options   Window    Help

                      #Program to create star pattern

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

                         Output

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

                          REVISIT

                           A  control structure  is  a  programming  language  construct  which affects  the  flow of the  execution  of a
                         program.
                           The statements that are executed in sequential order, i.e. one after the other without any jumps, are called
                         sequential statements.
                           When programmers are required to execute a particular set of statements depending upon a particular test
                         condition, a branching statement is required.
                           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.

                                                                                                       Flow of Control  89

| 86 87 88 89 90 91 92 93 94 95 96 |