REVIEWER For Midterm
REVIEWER For Midterm
Pint Command
• print : Produces text output on the console.
Import math
Use import math for clear and safe access to functions and
constants from the math module.
Week 4 – Control Structures: Looping A nested loop is a loop inside a loop.
Loops are a fundamental building block of any programming Week 4 – Control Structures: Selection
language.
Indentation is used in Python to delimit blocks.
While Loop
Executes a group of statements as long as a condition is Control structures provide a means for some statements to
True. be skipped or by-passed during execution, depending on the
result of a condition(s).
The end argument in the print function specifies what to
print at the end instead of the default newline. The if statement is the most simple decision-making
statement. It is used to decide whether a certain statement
An infinite loop is a type of loop that continues indefinitely or block of statements will be executed or not.
without any condition to break or exit the loop.
The if/else statement executes one block of statements if a
The else clause is only executed when your while condition certain condition is True, and a second block of statements
becomes false. If you break out of the loop, or if an if it is False.
exception is raised, it won’t be executed.
A nested if is an if statement that is the target of another if
For loops are used for sequential traversal. For example: statement.
traversing a list or string or array etc.
Compound Conditions - Have more than 1 conditional
Range expression.
loop through a set of code a specified number of times, we
can use the range() function. In Python, and, or, and not are logical operators used to
The range() function returns a sequence of numbers, combine conditional statements and evaluate truth values.
starting from 0 by default, and increments by 1 (by default),
and ends at a specified number.
Docstring
This is used to describe the functionality of the function.