PYTHON CONDITIONAL LOOPS
Docstrings Python Comment
The docstring comment is most commonly found in modules, functions, classes, and methods.
It's a Python string that's used for documentation.
The _doc_ attribute can be used to inspect the docstring of a function.
Indentation is usually done with four whitespaces. The degree of indentation is determined by the
user, but it must be uniform throughout the block.
IF-ELSE STATEMENT
Why use Loops
Looping reduces the difficulty of complex problems to a manageable level. It allows us to
change the program's flow so that instead of writing the same code over and over, we can
repeat it for a limited number of times. For example, instead of executing the print statement
10 times to print the first 10 natural numbers, we can print inside a loop that runs for up to 10
iterations.
© 2024 Athena Global Education. All Rights Reserved
Advantages of Loops
It allows you to reuse your code.
We do not have to write the same code over and over again when we use loops.
We can traverse the elements of data structures using loops (array or linked lists).
© 2024 Athena Global Education. All Rights Reserved