COMSC20 Ch. 4 - Conditionals

0.0(0)
Studied by 2 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:07 AM on 6/29/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

16 Terms

1
New cards

Block

A group of consecutive indented statements (same indentation.) that follow boolean (ex: after if statement)

2
New cards

Body

The block of statements in a compound statement that follows the header.

3
New cards

Boolean Expression

An expression that evaluates to either True or False. EX: print(3<5) → True

4
New cards

Boolean Function

A function that returns a boolean value. The only possible values of the bool type are False and True.

5
New cards

Boolean Value

There are exactly two boolean values:True and False. Boolean values result when a boolean expression is evaluated by the Python interpreter. They have type bool.

6
New cards

Branch

One of the possible paths of the flow of execution determined by conditional execution.

7
New cards

Chained Conditional

A conditional branch with more than two possible flows of execution. In Python chained conditionals are written with if ... elif ... else statements.

8
New cards

Comparison Operator

One of the operators that compares two values:==, !=, >,

9
New cards

Condition

The boolean expression after the if statement→ in a conditional statement that determines which branch is executed.

10
New cards

Conditional Statement / Selection statement

A statement that controls the flow of execution depending on some condition. In Python the keywords if, elif, and else are used

11
New cards

Logical Operator

One of the operators that combines boolean expressions: and, or, and not.

12
New cards

Modulus Operator

An operator, denoted with a percent sign (%), that works on integers and yields the remainder when one number is divided by another.

13
New cards

Nesting

One program structure within another, such as a conditional statement inside a branch of another conditional statement.

14
New cards

unary selection

Form of the if statement where the else clause is omitted entirely EX:

number = int(input("Enter a non-negative number: "))

if number < 0:
    print("Sorry, negative numbers are not allowed.")
    
print("Your number was", number)

the last print is always executed → could use else: pass if uncomfortable w/ no else statement

15
New cards

short-circuiting

When the evaluation of a logical expression stops bc the overall value is already known → EX: print(x >= 2 and y != 0 and (x/y) > 2) → if x >= 2 is false, neither y != 0 or (x/y)>2 is evaluated

16
New cards

guard

A comparison put in place to cause short circuit behavior and avoid a runtime error.guard

Explore top notes

note
AP Music Theory Ultimate Guide
Updated 1072d ago
0.0(0)
note
Human Geography Unit 5
Updated 347d ago
0.0(0)
note
Data Trends
Updated 1149d ago
0.0(0)
note
Fluids: chapter 8
Updated 480d ago
0.0(0)
note
AP Music Theory Ultimate Guide
Updated 1072d ago
0.0(0)
note
Human Geography Unit 5
Updated 347d ago
0.0(0)
note
Data Trends
Updated 1149d ago
0.0(0)
note
Fluids: chapter 8
Updated 480d ago
0.0(0)

Explore top flashcards

flashcards
Frans HCE 11
53
Updated 1094d ago
0.0(0)
flashcards
IMENICE
32
Updated 393d ago
0.0(0)
flashcards
abeka history 10 section 5.1
23
Updated 920d ago
0.0(0)
flashcards
Culture Quiz #2
24
Updated 473d ago
0.0(0)
flashcards
SAT Math Formulas
20
Updated 234d ago
0.0(0)
flashcards
Ap psych unit 1 vocab
36
Updated 933d ago
0.0(0)
flashcards
Frans HCE 11
53
Updated 1094d ago
0.0(0)
flashcards
IMENICE
32
Updated 393d ago
0.0(0)
flashcards
abeka history 10 section 5.1
23
Updated 920d ago
0.0(0)
flashcards
Culture Quiz #2
24
Updated 473d ago
0.0(0)
flashcards
SAT Math Formulas
20
Updated 234d ago
0.0(0)
flashcards
Ap psych unit 1 vocab
36
Updated 933d ago
0.0(0)