Any program’s architecture (simple or complex) requires the exploration of a variety of possible coding solutions. To achieve the program functionality we desire, it is important that we check the suitability of the possible solutions.
pass statements in Python let us move from one feature of the program to another. We also use them to test different areas of our code within the compiler while it is still under development.
break statement has the following characteristics:
It lets us:
# Example of a `break` statement in a `for` loop: fruit = ["apple", "orange", "banana", "pear", "mango"] for i in fruit: print(i) if i == "pear": print("You found a pear!") break
#Example of a `break` statement in a `while` loop: count = 0 while count < 12: count += 1 print(count) if count == 8: print("End of program.") break
continue statement has the following characteristics:
It lets us:
# Example of a `continue` statement in a `for` loop: for i in range (12): if i % 2 == 0: continue print(i)
# Example of a `continue` statement in a `while` loop: variable = 0 while variable < 12: variable += 1 if variable % 2 == 0: continue print(variable)
pass statement has the following characteristics:
pass statement is a nullifying statement, meaning it terminates any operations that precede it.
pass statement is particularly relevant for exploring the architecture of a function or a series of functions. It doesn’t execute anything beyond it, and it prevents the execution of anything that precedes it.
def new_function(): pass
pass statements in Python allow greater control and flexibility in coding by permitting useful exceptions to a program's architecture.
View all Courses