Module 3 Flashcards
an instruction that a Python interpreter can execute
Statement
Python statement ends with the token NEWLINE character. But we can extend the statement over multiple
lines using line continuation character (). This is known as an explicit continuation.
Multi-Line Statements
We can use parentheses () to write a multi-line statement. We can add a line continuation statement inside
it. Whatever we add inside a parentheses () will treat as a single statement even it is placed on multiple lines
Implicit continuation
contain (groups of) other statements; they affect or control the execution of those
other statements in some way.
Compound Statements
What are the Five compound statements?
if, while, for, try and with
It is a control flow statement that will execute statements under it if the condition is
true. Also known as a conditional statement.
if statement
repeatedly executes a code block while a particular
condition is true. Also known as a looping statement.
while statements
we can iterate any sequence or iterable variable. The
sequence can be string, list, dictionary, set, or tuple. Also known as a looping statement.
for statement
specifies exception handlers
try statements
Used to cleanup code for a group of statements, while the with statement allows
the execution of initialization and finalization code around a block of code.
with statements
Apart from the declaration and calculation statements, Python has various simple statements for a specific
purpose.
Simple Statements
is a null operation. Nothing happens when it executes. It is useful as a placeholder when a statement
is required syntactically, but no code needs to be executed.
The pass statement
are used to compute and write a value. An expression statement
evaluates the expression list and calculates the value.
Expression statements
used to delete objects/variables.
The del statement
we can return a value from a function when
called.
The return statement
contains the variable to delete separated by a comma.
target_list
used to import modules. We can also import individual classes from a module.
Python has a huge list of built-in modules which we can use in our code.
The import statement
used inside the loop to exit out of the loop
break Statement
skip the current iteration and move to the next iteration.
continue Statement
Terminate the current loop. Use the break statement to
come out of the loop instantly.
break