Glossary
For all the words that would be of benefit to know. If there is a word you believe should be on this list, please open an
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.Truth values are the results of comparison operations or logical (Boolean) operations.
- Definition: similar to "1", and considered TRUE in boolean logic
- Definition: similar to "0", and considered FALSE in boolean logic
The other logical operators. Each operator has their own truth table:
- Definition: will result into
True
only if both the operands areTrue
- Definition: used to invert the truth value
- Definition: will result into
True
if any the operands areTrue
- Definition: used for looping, generally when we know the number of times we want to loop with any type of sequence like a list or string.
- Definition: used to test if a sequence (list, tuple, string, etc.) contains a value. It returns
TRUE
if the value is present. Its secondary use is to traverse through a sequence in afor
loop.
- Definition: used for looping. The statements inside this type of loop will continue to execute until the condition for the
while
loop evaluates toFALSE
or abreak
statement is encountered.
- Definition: used for conditional branching or decision making.
- Definition: short for "else if" used for conditional branching or decision making.
- Definition: used for conditional branching or decision making if the condition is false; the last resort.
- Definition: used to alter the loop's normal behavior; this will end the smallest loop it is in and control flows to the statement immediately below the loop.
- Definition: used to alter the loop's normal behavior; causes to end the current iteration of the loop, but not the whole loop.
- Definition: used to define a new user-defined class - which is a collection of related attributes and methods that try to represent a real world situation.
- Definition: used to define a new user-defined function.
- Definition: coroutine keywords that denote the beginning of an asynchronous function (work in parallel). Usually followed by
await
keyword.
- Definition: coroutine keywords that denote the beginning of a promise within an asynchronous function.
NOTE: There can be as manyawait
keywords within a function as needed.
- Definition: used to delete the reference to an object.
- Definition: used to create an alias while importing a module, giving a different name to a module while importing it.
- Definition: used for testing object identity, by testing if the two variables refer to the same object. This will return
TRUE
if the objects are identical andFALSE
if not.
- Definition: special constant in python that represents the absence of a value or null value.
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.
Exceptions are errors that suggest something went wrong while executing the program. Some examples of errors that one could encounter are
IOError
, ValueError
, ZeroDivisionError
, ImportError
, NameError
, TypeError
. To catch exceptions, use try...except
blocks.- Definition: used with exceptions, where
try...except
blocks are used to catch exceptions if they fail thetry
set of instructions.
- Definition: used with exceptions, where
try...except
blocks are used to catch exceptions by trying out a set of instructions to see if an exception occur.
- Definition: to raise an exception explicitly.
- Definition: used with
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.
- Definition: to import specific attributes or functions into the current namespace, use
from...import
.
- Definition: used to import modules into the current namespace.
- Definition: used to declare that a variable inside the function is global (outside the function).
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.
- Definition: used to create an inline, anonymous function (function without a name), without a
return
statement, consisting of an expression that is evaluated and returned.
- Definition: used to declare that a variable inside a nested function (function inside a function) is not local to it, meaning it lies in the outer inclosing function. (similar to the
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.
- Definition: null statement where nothing happens when executed, mainly used as a placeholder.
- Definition: used inside a function to exit and return a value.
NOTE: If we do not return a value explicitly,NONE
is returned automatically.
- Definition: statement used to wrap the execution of a block of code within methods defined by the context manager.
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.
- Definition: used inside a function like a
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.
- Definition: used for debugging purposes by checking the internal state or if assumptions are true.
NOTE: If the assert condition is true, nothing will happen. But if the condition is false, the error -AssertionError
is raised.
Last modified 1yr ago