Python: Control flow Flashcards

1
Q

What is a Boolean expression?

A

A statement that can either be true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does this variable mean?
[==]

A

Equals

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does this variable mean?
!=

A

Not equals

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does this code do?
type(random_variable)

A

Checks what type is the variable
Ex: checks if it’s assigned to a text or Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define following relational operators
1. >
2. >=
3.<
4.<=

A
  1. Greater than
  2. Greater than or equal to.
  3. Less than.
  4. Less than or equal to.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the following Boolean operator do?
And

A

Combines two Boolean expressions and checks if BOTH are true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the following Boolean operator do?
or

A

Combines two expressions and checks if either is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the following Boolean operator do?
not

A

When applied to any Boolean expression, it reverses Boolean value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does else statement do?

A

Describe what we want our code to do when certain conditions are not met.
Ex:
if weekday:
print(“wake up at 6:30”)
else
print(“sleep in”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does elif (else if) statement do?

A

Checks another condition after the previous [if] statements conditions aren’t met.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly