IT101-1L midterms lesson 8-12 Flashcards
(97 cards)
allow you to make decisions and execute different code blocks based on certain conditions.
selection structures
allows you to execute a block of code only if a specified condition is True.
if statement
extends the if statement by providing an alternative code block to be executed when the condition is False
if-else statement
t allows you to evaluate multiple conditions in a sequential manner. It is used when you have more than two possible outcomes
if-elif-else statement
are used in programming to compare values and determine the relationship between them.
Relational operators
is used within loops (such as for or while) to exit the loop immediately.
break statement
Checks if two values are equal.
== (equal to):
Checks if two values are not equal.
!= (not equal to):
> (greater than): Checks if the left operand is greater than the right operand.
> (greater than):
Checks if the left operand is less than the right operand.
< (less than):
Checks if the left operand is greater than or equal to the right operand.
> = (greater than or equal to):
Checks if the left operand is less than or equal to the right operand.
<= (less than or equal to):
The and operator returns True if both of its operands are True, and False otherwise.
and:
The or operator returns True if at least one of its operands is True, and False otherwise.
or:
: The not operator reverses the logical state of its operand. If the operand is True, the not operator returns False, and if the operand is False, it returns True.
not
means that the second operand of an and or or operator is not evaluated if the outcome can be determined solely by evaluating the first operand.
Short-circuit evaluation
you can control the flow of your program and stop the loop execution based on certain conditions.
break statement,
is an expression that evaluates to either True or False.
condition
The _________ statement can be extended to include multiple conditions using the _____
if…else, elif
By using _________, you can create decision trees with multiple branches, allowing your program to respond differently based on different conditions.
multiple elif clauses
refer to the practice of placing one or more if…else statements inside another if or else block.
Nested decisions
, are fundamental programming constructs that allow you to repeat a code block multiple times based on specified conditions.
Iterative structures, commonly known as loops
evaluates the condition before executing the code block.
The while loop
in Python is used to iterate over elements of an iterable
The for loop