Unit 4 Flashcards
Branching
4.1 - If-Else Branches (General)
What is a branch?
a sequence of statements only executed under a certain condition
4.1 - If-Else Branches (General)
What does an if/else statement do?
if a statement is true, perform x command
else / otherwise, perform y command
4.2 - Detecting Equal Values with Branches
How do you check if two values are and are not equal?
using x and y, code format
use x = y
if x == y
if x != y
4.2 - Detecting Equal Values with Branches
What does elif
do?
acts as a secondary if statement with less imporance
4.2 - Detecting Equal Values with Branches
What is Boolean Logic?
or just a Boolean value
a binary system of representing information (true/false system)
4.3 - Detecting Ranges with Branches (General)
How do you check if a value is within a range?
x between y and z, in code format
if y < x < z
orif y > x and x < z
4.4 - Detecting Ranges with Branches
What are relational operators?
definition & symbols
operators used for comparing values<
>
<=
>=
=
and ==
4.4 - Detecting Ranges with Branches
What is operator chaining?
just give an example, x y and z
x < y < z
4.5 - Detecting Ranges Using Logical Operators
What is a logical operator?
an operator which conforms to Boolean logic
4.5 - Detecting Ranges Using Logical Operators
What are the three logical operators?
and
true if both operands are trueor
true if either operand is truenot
true if opposite opperand is false
4.6 - Detecting Ranges with Gaps
What is a fall-through?
a programming problem where improper ranges lead to values “falling through” gaps
x < 10
x > 10
but what if x == 10?
4.7 - Detecting Multipe Features with Branches
What is a nested if/else statement?
an if/else statement within another if/else statement
4.8 - Comparing Data Types and Common Errors
Why should you avoid using equality operators with floating-point numbers?
equality operators might inaccurately represent the floats
4.9 - Membership and Identity Operators
What are the two membership operators and what do they do?
in
and not in
determines if left operand is featured in right operand (container)
4.9 - Membership and Identity Operators
What are the two identity operators and what do they do?
is
and is not
checks if two operands are bound to the same object