Chapter 6: Making Choices and Decisions - 6.1 Flashcards

1
Q

6.1

What do we use if we want to compare whether the two variables are the same?

A

We use the double assignment operator
i.e. x==y, which entails inquiring the program if value of x is equal to y. If they are equal, the condition is met and statement will evaluate to true or else false.

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

What is the comparison operator for not equal?

A

!=

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

What is the comparison operator for greater than?

A

5>2

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

What is the comparison operator for smaller than?

A

2<5

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

What is the comparison operator for greater than or equal to?

A

5>=2

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

What is the comparison operator for smaller than or equal to?

A

2<=5

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

What are the three logical operators that are useful if we want to combine multiple conditions?

A

and, or, not

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

What does the “and” operator do?

A

It returns True if all conditions are met, else it will return false. For example, the statement “5==5 and 2>1” will return true as both the conditions are true.

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

What does the “or” operator do?

A

The “or” operator returns True is at least one condition is met. For example, the statement “5>2 or 7>10 or 3==2” will yield True as the first condition is met

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

What does the “not operator” do?

A

The “not”operator returns True if the condition after the “not” keyword is false. The statement not 2>5 will return True since 2 is not greater than 5.

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