Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 148 - CodePilot V5.0 C7
P. 148

    Program 18 To print a right-angled triangle using the pattern of stars.
                                     *
                                     **
                                     ***

                                     ****
                                     *****

                          Program18.py                                                            Output
                       File  Edit  Format   Run    Options   Window    Help                    *
                                                                                               **
                       for i in range(1, 6):
                                                                                               ***
                           print("*" * i)
                                                                                               ****
                                                                                               *****

                      TECH
                         T      ¢   Expression: A combination  of values, variables, operators and functions  that  Python
                         E         evaluates to produce a result.
                         R
                        M
                         S      ¢   Interpreter: A program that reads and executes Python code line by line, converting it to
                                   machine code.

                                    Execution:  The  process  of  running code,  where the  interpreter  executes  instructions  to
                                ¢
                                   produce results.

                      REWIND RUN

                      «   The order in which program statements are executed is called the flow of control.
                      «   The if…else… statement lets your program choose between two options.
                      «   The nested if structure allows you to place one if statement inside another.
                      «   The ternary operator allows you to perform conditional checks and assign values or execute expressions
                         in a single line.

                      «   The for loop repeats a block of statements a fixed number of times.
                      «   A while loop repeats a set of instructions as long as a given condition is true.
                      «   Python offers two jump statements—break and continue, which are used within loops.

                       146
                            CodePilot (V5.0)-VII

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