Glossary
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 🔑
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
Truth values are the results of comparison operations or logical (Boolean) operations.
True
TrueDefinition: similar to "1", and considered TRUE in boolean logic
False
FalseDefinition: similar to "0", and considered FALSE in boolean logic
Logical Operators
The other logical operators. Each operator has their own truth table:
and
andDefinition: will result into
Trueonly if both the operands areTrue
not
notDefinition: used to invert the truth value
or
orDefinition: will result into
Trueif any the operands areTrue
Loops
for
forDefinition: 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.
in
inDefinition: used to test if a sequence (list, tuple, string, etc.) contains a value. It returns
TRUEif the value is present. Its secondary use is to traverse through a sequence in aforloop.
while
whileDefinition: used for looping. The statements inside this type of loop will continue to execute until the condition for the
whileloop evaluates toFALSEor abreakstatement is encountered.
if
ifDefinition: used for conditional branching or decision making.
elif
elifDefinition: short for "else if" used for conditional branching or decision making.
else
elseDefinition: used for conditional branching or decision making if the condition is false; the last resort.
break
breakDefinition: 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.
continue
continueDefinition: used to alter the loop's normal behavior; causes to end the current iteration of the loop, but not the whole loop.
User Defined Structures
class
classDefinition: 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.
def
defDefinition: used to define a new user-defined function.
async
asyncDefinition: coroutine keywords that denote the beginning of an asynchronous function (work in parallel). Usually followed by
awaitkeyword.
await
awaitDefinition: coroutine keywords that denote the beginning of a promise within an asynchronous function.
NOTE: There can be as many
awaitkeywords within a function as needed.
References
del
delDefinition: used to delete the reference to an object.
as
asDefinition: used to create an alias while importing a module, giving a different name to a module while importing it.
is
isDefinition: used for testing object identity, by testing if the two variables refer to the same object. This will return
TRUEif the objects are identical andFALSEif not.
None
NoneDefinition: special constant in python that represents the absence of a value or null value.
NOTE: It is an object with the datatype
NoneType. There cannot be multipleNoneobjects but can assign it to variables which would be equal to one another.Nonedoes NOT implyFalse,0, or empty list/string/dict.
Exceptions
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...exceptblocks.
except
exceptDefinition: used with exceptions, where
try...exceptblocks are used to catch exceptions if they fail thetryset of instructions.
try
tryDefinition: used with exceptions, where
try...exceptblocks are used to catch exceptions by trying out a set of instructions to see if an exception occur.
raise
raiseDefinition: to raise an exception explicitly.
finally
finallyDefinition: used with
try...exceptstatements 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.
Module Abstractions
from
fromDefinition: to import specific attributes or functions into the current namespace, use
from...import.
import
importDefinition: used to import modules into the current namespace.
Variable Declarations
global
globalDefinition: 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.
lambda
lambdaDefinition: used to create an inline, anonymous function (function without a name), without a
returnstatement, consisting of an expression that is evaluated and returned.
nonlocal
nonlocalDefinition: 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
globalkeyword).
NOTE: If you need to modify a non-local variable inside a nested function, then we must declare it with
nonlocal. Otherwise a local variable with that name is created inside the nested function.
Function Properties
pass
passDefinition: null statement where nothing happens when executed, mainly used as a placeholder.
return
returnDefinition: used inside a function to exit and return a value.
NOTE: If we do not return a value explicitly,
NONEis returned automatically.
with
withDefinition: 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 ofwithstatement ensures that the__exit__method is called at the end of the nested block. Tis concept is similar to the use oftry...finallyblock.
yield
yieldDefinition: used inside a function like a
returnstatement, 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.
Debugging
assert
assertDefinition: 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 -
AssertionErroris raised.
Last updated
Was this helpful?