issue
.Keywords
in programming languages are specific words that are reserved to communicate specific things to the computer. These words remain consistent across all uses of the programming language.True
False
and
True
only if both the operands are True
not
or
True
if any the operands are True
for
in
TRUE
if the value is present. Its secondary use is to traverse through a sequence in a for
loop.while
while
loop evaluates to FALSE
or a break
statement is encountered.if
elif
else
break
continue
class
def
async
await
keyword.await
NOTE: There can be as manyawait
keywords within a function as needed.
del
as
is
TRUE
if the objects are identical and FALSE
if not.None
NOTE: It is an object with the datatypeNoneType
. There cannot be multipleNone
objects but can assign it to variables which would be equal to one another.None
does NOT implyFalse
,0
, or empty list/string/dict.
IOError
, ValueError
, ZeroDivisionError
, ImportError
, NameError
, TypeError
. To catch exceptions, use try...except
blocks.except
try...except
blocks are used to catch exceptions if they fail the try
set of instructions.try
try...except
blocks are used to catch exceptions by trying out a set of instructions to see if an exception occur.raise
finally
try...except
statements to close up resources or file streams. This ensures that the block of code inside it gets executed even if there is an unhandled exception.from
from...import
.import
global
NOTE: As a global variable, if we need to read the value of the variable we do not need to define it as global. If we need to modify the value of a global variable inside a function, then we must declare it with global, otherwise a local variable is created.
lambda
return
statement, consisting of an expression that is evaluated and returned.nonlocal
global
keyword).NOTE: If you need to modify a non-local variable inside a nested function, then we must declare it withnonlocal
. Otherwise a local variable with that name is created inside the nested function.
pass
return
NOTE: If we do not return a value explicitly,NONE
is returned automatically.
with
NOTE: "Context Manager" is a class that implements__enter__
and__exit__
methods. Use ofwith
statement ensures that the__exit__
method is called at the end of the nested block. Tis concept is similar to the use oftry...finally
block.
yield
return
statement, however it returns a generator.NOTE: A Generator is an iterator that generates one item at a time. A large list of value will take up a lot of memory. Generators are useful in this situation as it generates only one value at a time instead of storing all the values in memory.
assert
NOTE: If the assert condition is true, nothing will happen. But if the condition is false, the error -AssertionError
is raised.