Page 381 - Ai_417_V3.0_C9_Flipbook
P. 381

Identifiers (Names)

                 Identifiers are the user-defined names of variables, list, dictionary, tuples, classes, etc. They identify an element
                 in Python.

                 Naming the identifiers follows the given rules:
                    • It can contain alphabets (uppercase, lowercase), numbers or underscore(_).
                    • Must begin with a letter (a-z, A-Z) or an underscore (_).

                    • No special characters like $, period(.), space, etc. are allowed.
                    • It should not be a Python keyword.
                    • It is case-sensitive (uppercase and lowercase letters are different).
                 Example of invalid identifiers are:

                 First name   :   Spaces not allowed
                 Last&Name  :    Cannot have special character
                 9thclass     :   Cannot begin with number
                 else         :   Keyword not allowed
                 Examples of valid identifiers are:
                 Myclass, class9, Address, address, first_name, city, student_id, data123

                 Literals

                 It is defined as any data stored in a variable. It is a constant whose value never change during the program
                 execution. Different types of literals in Python are as follows:
                    • String literals: They are sequence of words enclosed in single, double, or triple quotes. For example,
                            "Hello"
                            'Python'

                    • Numeric literals: They can be integer, float or complex. For example,
                            14
                            20.5
                            2+5j

                    • Boolean literals: They can be True or False. For example,
                            True

                    • None literals: Only None is a special literal. It means something not yet created.

                 Punctuators

                 Punctuators are special symbols used in Python to organise statements and expressions. Most commonly used
                 punctuators in Python are:

                 ' " # \ () {} [] @ , : . =

                 Operators

                 Operators are special symbols used to perform mathematical, logical and relational operations on variables
                 and values. The variables or values on which the operators work are called operands. Some commonly used
                 operators in Python are arithmetic operators, relational operators, logical operators and augmented assignment
                 operators.


                                                                                        Introduction to Python  379
   376   377   378   379   380   381   382   383   384   385   386