Ch. 5 Flashcards

1
Q

= vs ==?

A

= assigns, == means equals

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

!=?

A

Not equal

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

What does “and” do when checking for conditions?

A

Will check two conditions simultaneously (both must be satisfied for true)

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

What does “or” do when checking for conditions?

A

Will check two conditions simultaneously (only one must be satisfied for true)

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

How do you check if a value is in a list?

A

Use “in”
Example: value in list_name
will say true or false

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

How do you check if a value is not in a list?

A

Use “not in”

Example: if variable not in list_name

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

A boolean value is either?

A

True or False

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

For if statements, how do you apply indentation?

A

Same as for loops! Must indent after the if statement if you want that line of code to be associated with it.

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

The else block is a catch all statement, what does that mean?

A

It matches any condition that wasn’t matched by a specific if or elif test. ( be careful though because that can sometimes include bad or invalid data)

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

When applying .lower() what happens?

A

It returns a new string (lowercase), but does not modify the original

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

Are strings mutable or immutable?

A

immutable

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

Empty lists are boolean ___. Not empty are boolean ___.

A

False, True

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

How do lists cast to boolean, strings, and integers?

A

empty list, strings and zero cast to false, non empty lists, strings and numbers cast to true

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