Keywords and identifiers in python
Python Keywords
Keywords are reserved words with a predefined meaning. These words can not be used as a function name, variable name, class name, etc. They're written in lower case except for True, False, and None and are case-sensitive.An identifier is a stoner- defined name used to identify realities like class, functions, variables, etc. They're used to separate one reality from another.
The identifier is a combination of characters, integers, and a special symbol underscores. Underscore can be used formulti-word variables likecount_one,container_2, etc.
Python is a case-sensitive programming language that makes identifiers also case-sensitive. For illustration, Count and count are two different identifiers in Python.
It's advised to give a meaningful name to the identifier to make the law accessible. For illustration, a variable to store the count of figures can be named “ count” rather of “c.”
The identifier is a combination of characters, integers, and a special symbol underscores. Underscore can be used formulti-word variables likecount_one,container_2, etc.
Python is a case-sensitive programming language that makes identifiers also case-sensitive. For illustration, Count and count are two different identifiers in Python.
It's advised to give a meaningful name to the identifier to make the law accessible. For illustration, a variable to store the count of figures can be named “ count” rather of “c.”
There are 33 keywords in Python. Let’s go through them one by one.
Keyword | Description |
and | a logical operator that returns true if both the operands are true or else returns false |
as | used to create an alias |
assert | used during debugging to check the correctness of code |
break | Control statement used to break from a loop |
class | used to define a class |
continue | control statement used to continue to the next iteration of a loop |
def | used to define a function |
del | used to delete the reference to the object |
elif | condition statement used for the else if condition |
else | conditional statement that is executed if the if condition is false |
except | Used in exceptions |
False | boolean value |
finally | used with exceptions to execute a block of code that will be executed no matter if there is an exception or not |
for | Used in for loop |
from | import specific parts of a module |
global | Used to declare a global variable |
if | a conditional statement that executes if the condition is true |
import | Used to import a module |
in | used to check if a value is present in a list, tuple, etc. |
is | used to check if the two variables are equal or not |
lamda | used to create an anonymous function |
None | used to represent a null value |
nonlocal | used to declare a non-local variable |
not | a logical operator that returns true if the operand is false or else returns false |
or | a logical operator that returns true if any one of the operands is true or else returns false |
pass | a null statement that does not do anything |
raise | Used to raise an exception |
return | used to exit a function and return a value |
True | boolean value |
try | used to make a try-except statement |
while | used in while loop |
with | used to simplify exception handling |
yield | used to end a function and return a generator |
Comments
Post a Comment