Keywords in Python
§ Reserved word is those word which already define and
who’s meaning already known by compiler.
§ Keywords are the reserved words in Python which convey
special meaning to the compiler to perform specific task.
§ Keywords are the reserved words in Python. We cannot
use a keyword as variable name, function name or any other identifier.
§ There are 33 reserved words in Python.
True, False, None
and, or, not, is
if,else, elif
while, for, break,continue,return,in,yield
try,except,finally,raise,assert
import, from, as, class, def, pass, global, nonlocal5, lambda,del,with
Note:-1. All reserved words contains only alphabet symbols
2. except first 3(True, False, None) remaining all in lowercase.
e:g-
a=True //valid
a=true //invalid
a=none //invalid
a=None //valid
>>> 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']
Post a Comment