Tokens
Tokens
Rule 3
Rule 2
Rule 1
Identifiers
Some Valid Identifiers:
Literals
► Literals are the data items that have a fixed or
constant value
String Literals
► A string literal is a sequence of characters surrounded
by Quotes (Single, Double or Triple Quotes).
Multiline string
>>>Txt2 = “Hello\
World”
>>>Txt3 =‘’’Hello World”’
Numeric Literals
► Numeric Literals are numeric values like integer
floating point number or a complex number
float complex
• complex
number
literals
Numeric Literals
► integer literals
Boolean Boolean
True False
Special Literal – None(empty legal value)
VID-REC
• Contains special character -(hyphen)
2020RNO
• Starting with a Digit
continue
• Reserved keyword
Emp.Code
• Contains special character . (dot)
Operators in Python
► Operators are the symbols or words that perform some kind
of operation on given values (operands) in an expression and
returns the result.
arithmetic • +,-,/,*,%,**,//
bitwise • &, ^, |
‘ ‘’ “” # \ (){}[] @,
, : .;
Tokens in Python
Keywords are the reserve words of python which have a special meaning for
the interpreter.
Identifiers are the name given to the different programming elements like
variables, objects, classes, functions, lists, dictionaries etc.
Literals are the data items that have a fixed /constant value.
Operators are the symbols or words that perform some kind of operation on
given values (operands) in an expression and returns the result.