Page 203 - Ai Book - 10
P. 203

PYTHON INDENTATION

        Most of the programming languages provide indentation for better code formatting and don’t enforce to have
        it. However, in Python, it is mandatory to obey the indentation rules. Typically, we indent each line by four
        spaces (or by the same amount) in a block of code.
        Python uses the colon symbol (:) and indentation for showing where blocks of code begin and end. All blocks
        start with a colon and then contain the indented lines below it.
        In the examples, earlier, you might have seen simple expression statements which didn’t have the indentation.
        However, for creating compound statements, the indentation will be utmost necessary.

                  if a>b:       # if block starts here
                    print(a) # This is part of the if block
                  else:         # else must be at the same level as if
                    print(b) # This line is part of the else block

              Kno
              Knowledge Botwledge Bot

          Any statement, without indentation will raise an error.


               Pop
               Pop Quiz                                     Quiz

          Name the following.
          1.  A loop used for definite number of iterations.                      _____________________________
          2.  A loop used for unknown number of iterations.                       _____________________________
          3.  A conditional statement used for only two conditions.               _____________________________




                                                      K Keyey  TTermserms



         u   Anaconda
             Anaconda is a free and open-source distribution of Python for scientific computing. Anaconda includes tools
             such as Anaconda Prompt and Anaconda Navigator, providing a command-line interface and a graphical
             user interface, respectively.

         u   Jupyter Notebook
             Jupyter Notebook is a powerful tool to integrate code, text, and graphics in a document, commonly used by
             data scientists. The interface includes a menu bar, toolbar, and various menus such as File, Edit, View, Insert,
             Cell, Kernel, Widgets, and Help.

         u   Introduction to Python
             Python is a widely used, easy-to-learn, cross-platform, and object-oriented programming language. Python
             is used in web development, machine learning, AI, data analysis, desktop GUI, and more. Recap of basics
             including the print function, comments, keywords, variables, and data types.

         u   IDLE
             IDLE is an acronym of Integrated Development Environment which is the standard development environment
             of Python.



                                                                                                              77
                                                                                                              77
   198   199   200   201   202   203   204   205   206   207   208