Keywords and identifiers in python

 Python Keywords

Keywords are reserved words with a predefined meaning. These words can not be used as a function namevariable nameclass name, etc. They're written in lower case except for True, False, and None and are case-sensitive.

An identifier is a stonerdefined name used to identify realities like classfunctions, variables, etc. They're used to separate one reality from another.

The identifier is a combination of charactersintegers, 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 illustrationCount 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.


KeywordDescription
anda logical operator that returns true if both the operands are true or else returns false
asused to create an alias
assertused during debugging to check the correctness of code
breakControl statement used to break from a loop
classused to define a class
continuecontrol statement used to continue to the next iteration of a loop
defused to define a function
delused to delete the reference to the object
elifcondition statement used for the else if condition
elseconditional statement that is executed if the if condition is false
exceptUsed in exceptions
Falseboolean value
finallyused with exceptions to execute a block of code that will be executed no matter if there is an exception or not
forUsed in for loop
fromimport specific parts of a module
globalUsed to declare a global variable
if a conditional statement that executes if the condition is true
importUsed to import a module
inused to check if a value is present in a list, tuple, etc.
isused to check if the two variables are equal or not
lamdaused to create an anonymous function
Noneused to represent a null value
nonlocalused to declare a non-local variable
nota logical operator that returns true if the operand is false or else returns false
ora logical operator that returns true if any one of the operands is true or else returns false
passa null statement that does not do anything
raiseUsed to raise an exception
returnused to exit a function and return a value
Trueboolean value 
tryused to make a try-except statement
whileused in while loop
withused to simplify exception handling
yieldused to end a function and return a generator

Comments

Popular posts from this blog

Tanh Activation Function

Sigmoid Activation Function And Its Uses.

Unleashing Creativity: The Latest Frontier of Animation AI