23 1 2025
23 1 2025
1. ASCII
2. UNICODE
Tokens
Token is a smallest individual unit within program.
1. Keywords
2. Identifiers
3. Literals
4. Data types
5. Operators
Keywords
Python language related words are called keywords
Keywords are reserved words, the meaning these words are
reserved by python translator (OR) the syntax or meaning of
these words understands by python translator.
How to find list of keywords supported by python?
>>> import keyword
>>> keyword.kwlist
['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']
>>> len(keyword.kwlist)
35
Identifiers
Identifiers are user defined words or programmer defined words
Identifiers are used to identify programming elements
1. Variables
2. Functions
3. Classes
4. Constants
5. Modules
6. Packages
Rules
>>> x=100
>>> y=200
>>> x
100
>>> y
200
>>> pass=100
SyntaxError: invalid syntax
>>> import=1
SyntaxError: invalid syntax
>>> PASS=100
>>> PASS
100
>>> _a=100
>>> _a_=200
>>> _=300
>>> __=400
>>> _a
100
>>> _a_
200
>>> _
300
>>> __
400
>>> amt$=100
SyntaxError: invalid syntax
>>> $amt=100
SyntaxError: invalid syntax
>>> a=10
>>> a
10
>>> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=100
>>> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
100
>>> A=100
>>> a=200
>>> A
100
>>> a
200