Page 59 - Information_Practice_Fliipbook_Class11
P. 59

Below we make some observations and give some suggestions for constructing identifiers:
               It is clear from the above rules that an identifier cannot start with a digit.

               Although an identifier may be of any length, we prefer to keep it short and meaningful. For example, to denote the
              roll number, name, and marks of a student, we may use rollNo, name, and marks as identifiers rather than a,
              b, and c, which do not relate them to the purpose for which they are used. We also avoid too long names such as
              roll_Number, student_Name, and student_Marks, unless necessary to make the context clear.
               The identifiers are case-sensitive. So, name, Name, and NAME are three distinct identifiers.

               An identifier must be different from any of the keywords in the Python language.
               Blank spaces within an identifier are disallowed.
               The special symbols, such as !,@,#,$,%,^,&,*,(,), cannot be included in an identifier.
            In this book, we prefer to use the variable names in camelCase. Thus, we capitalize the first letter of every logically
            meaningful part of a variable name. For example, we prefer to use the variable name rollNo, instead of the variable
            name rollno, which is harder to read. Some people prefer to use an underscore character to separate different
            logically meaningful parts of a variable name. Thus, it is also fine to use the variable name roll_no instead of
            rollNo. However, it is good practice to adopt a style and stick to it.

            3.2.3 Literals

            A literal refers to a constant or a fixed value. For example, 100 and 67.24 are numeric literals, 'India', and
            "Govt SR Secondary School" are string literals. Consider the following statements:
            num = 100                             (num is assigned the numeric literal 100)

            country = 'India'                   (country is assigned the string literal  'India' )
            average = 67.24                     (average is assigned floating-point literal 67.24)




            A string literal is typically enclosed within single quotes or double quotes. Python allows
            multi-line strings. A multi-line string is enclosed in triple quotes, for example:
            '''Rashmeet Kaur
            Airforce School, Patiala
            Punjab'''


            3.2.4 Delimiters

            Delimiters are symbols used to separate various tokens in a statement. Python uses the following delimiters:
            (       )       [       ]       {       }
            ,       :       .       ;       @       =       ->

            +=      -=      *=      /=      //=     %=      @=
            &=      |=      ^=      >>=     <<=     **=
            The last two rows in the above list include delimiters, which are also operators. In addition to the above list, the
            following characters have special meaning as part of other tokens:
            '       "       #       \

            3.2.5 Operators
            Operators are tokens that perform a particular operation on the given values, called operands. An operand may be a
            constant or a variable.





                                                                                    Basics of Python Programming  45
   54   55   56   57   58   59   60   61   62   63   64