Deck 6: Conditionals

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

1/5

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:27 PM on 8/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

6 Terms

1
New cards

What does this print if expression = 4.2 and threshold = 2.0?
if expression > threshold:

print('Gene is upregulated')

else:

print('Gene expression is normal')

"Gene is upregulated" (4.2 > 2.0 is True)

2
New cards

Why use if/else instead of two separate if statements checking opposite conditions?

if/else guarantees exactly one branch runs, making the "exactly one of these happens" relationship explicit and safe from accidental edits later

3
New cards

In an if/elif/elif/else chain, which condition wins if multiple are true?

The first one that's true, checked top to bottom → the rest are skipped even if they'd also be true

4
New cards

Why does condition order matter in an elif chain (e.g. checking > 5 before > 2)?

If a broader condition (> 2) came first, it would catch values that should have matched a more specific condition (> 5), so the more specific condition never gets reached — put the most specific condition first.

5
New cards

What do and, or, and not do in a conditional?

and requires both sides true; or requires at least one side true; not flips true to false or false to true.

6
New cards

How does pandas' condition-combining syntax differ from plain Python's and/or?

pandas uses & and | instead of and/or when combining conditions across whole DataFrame columns.