Page 229 - Ai_V1.0_Class9
P. 229

Following is the list of keywords displayed by running the above commands:

                 ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class',
                 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global',
                 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise',
                 'return', 'try', 'while', 'with', 'yield']
                 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  227
   224   225   226   227   228   229   230   231   232   233   234