Page 115 - ComputerGenius_V2.1_Class8
P. 115

Example:
                 a=10
                 a=20

                 Initially, the value of variable ‘a’ was 10. Later it’s
                 changed to 20.

                 Python Keywords

                 Python has a set of keywords that are reserved words and has a special meaning. They cannot be used
                 as variable names, function names, or any other identifiers. Some of the keywords are as follows:


                                       False        class       finally        is        return

                                       None       continue        for       lambda         try


                                       True          def         from      nonlocal       while

                                        and          del        global        not         with

                                        as           elif         if           or         yield


                                      assert        else        import       pass         raise

                                       break       except         in



                 Comments in Python

                 In Python, comments are used to explain code and are ignored by the interpreter. There are two
                 types of comments:
                 l    Single-line  comments:  Use  the  #  symbol.  Everything  after  #  on  the  same  line  is  considered  a
                   comment.

                   Example:
                    #This is a single-line comment
                 l   Multi-line comments: Use triple quotes (''' or """) for block comments.
                   Example:
                    ' ' '
                    This is a multi-line comment.
                    It spans multiple lines.

                    ' ' '

                 Python Operators

                 Operators are special symbols in Python that carry out arithmetic or logical computation. The value
                 that gets operated on is called an ‘Operand’. For example: 2+3=5, here, 2 and 3 are ‘Operands’. The
                 symbol ‘+’ is known as the ‘Operator’.


                                                                                            Basics of Python  113
   110   111   112   113   114   115   116   117   118   119   120