Lecture 4: Boolean Expressions and Conditionals

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/24

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering procedural knowledge, boolean expressions, relational and Boolean operators, and Python conditionals (if, elif, else) including indentation and common patterns.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

25 Terms

1
New cards

Boolean Expressions

Expressions that evaluate to True or False and are used to control program flow in conditionals.

2
New cards

Relational Operators

Operators that compare two values to produce a Boolean result (e.g., \text{==}, \text{!=}, \text{

3
New cards

Equality (==)

Operator that checks if two values are equal; note that \text{=} is used for assignment.

4
New cards

Assignment (=)

Operator that assigns a value to a variable.

5
New cards

Inequality (!=)

Operator that tests whether two values are not equal.

6
New cards

Less Than (<)

Operator that tests whether one value is smaller than another.

7
New cards

Greater Than (>)

Operator that tests whether one value is larger than another.

8
New cards

Less Than or Equal (<=)

Operator that tests whether a value is less than or equal to another.

9
New cards

Greater Than or Equal (>=)

Operator that tests whether a value is greater than or equal to another.

10
New cards

Boolean Operators

Operators that combine Boolean values: \text{and}, \text{or} , \text{not}.

11
New cards

and

True only if both operands are True; otherwise False.

12
New cards

or

True if at least one operand is True; otherwise False.

13
New cards

not

Logical negation that inverts a Boolean value.

14
New cards

Order of Operations (Boolean Expressions)

Rules for evaluating expressions: \text{not} before \text{and} before \text{or}; relational operators before Boolean operators; use parentheses for clarity.

15
New cards

Parentheses

Used to group parts of an expression to enforce order of evaluation.

16
New cards

Boolean Literals

The literals \text{True} and \text{False} used as Boolean values in conditions.

17
New cards

Between 0 and 100 Inclusive

A common range check example: \text{(variable >= 0) and (variable <= 100)}.

18
New cards

Conditional

A programming construct that selects a branch of code to execute based on a boolean condition.

19
New cards

Sequential

A programming construct where statements are executed one after another in order.

20
New cards

Indentation

In Python, indentation defines blocks of code; four spaces per level is common and required for blocks.

21
New cards

The if Statement

A conditional that introduces a branch; format: \text{if :} followed by an indented block.

22
New cards

The if-else Statement

Conditional with two branches: execute the first block if condition is True; otherwise execute the \text{else} block.

23
New cards

The if-elif-else Statement

Multiple conditional branches; the first True condition's block is executed; others are skipped until \text{else}.

24
New cards

Nested Branches

An \text{if/elif/else} statement inside another conditional block to reflect complex logic; requires consistent indentation.

25
New cards

First True Expression Wins

In an \text{if-elif-else} chain, the first condition that evaluates to True is executed and later conditions are ignored.