Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 95 - 2629_Devagiri_C-8
P. 95

    Program 13    To print a pattern using while loop.
                                    @@@@@
                                    @@@@
                                    @@@
                                    @@
                                    @
                         Program13.py

                      File  Edit  Format   Run    Options   Window    Help

                      #Program to show a pattern using while loop.
                      a = 5
                      while a>= 1:
                          print("@"*a)
                          a -= 1

                         Output

                      @@@@@
                      @@@@
                      @@@
                      @@
                      @

                     TECH
                        T      ¢   Expression: A combination  of values, variables, operators and functions  that  Python
                        E         evaluates to produce a result.
                       R
                       M       ¢   Interpreter: A program that reads and executes Python code line by line, converting it to
                        S         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.

                                                                                                                      93
                                                                                                   Networks Around Us

| 90 91 92 93 94 95 96 97 98 99 100 |