Python Keywords
Python Keywords are special
reserved words that convey a special meaning to the compiler/interpreter. Each
keyword has a special meaning and a specific operation. These keywords can't be
used as a variable. Following is the List of Python Keywords.
|
True |
False |
None |
and |
as |
|
asset |
def |
class |
continue |
break |
|
else |
finally |
elif |
del |
except |
|
global |
for |
if |
from |
import |
|
raise |
try |
or |
return |
pass |
|
nonlocal |
in |
not |
is |
lambda |
Consider the following
explanation of keywords.
- True - It represents the Boolean true, if the given condition is true,
then it returns "True". Non-zero values are treated as true.
- False - It represents the Boolean false; if the given condition is
false, then it returns "False". Zero value is treated as false
- None - It denotes the null value or void. An empty list or Zero can't
be treated as None.
- and - It is a logical operator. It is used to check the multiple
conditions. It returns true if both conditions are true. Consider the
following truth table.
|
A |
B |
A
and B |
|
True |
True |
True |
|
True |
False |
False |
|
False |
True |
False |
|
False |
False |
False |
5. or - It is a logical
operator in Python. It returns true if one of the conditions is true. Consider
the following truth table.
|
A |
B |
A
and B |
|
True |
True |
True |
|
True |
False |
True |
|
False |
True |
True |
|
False |
False |
False |
6. not -
It is a logical operator and inverts the truth value. Consider the following
truth table.
|
A |
Not
A |
|
True |
False |
|
False |
True |
7. assert - This
keyword is used as the debugging tool in Python. It checks the correctness of
the code. It raises an AssertionError if found any error in the code and also prints the
message with an error.
0 Comments