Chapter 6: Making Choices and Decisions - 6.1 Flashcards
6.1
What do we use if we want to compare whether the two variables are the same?
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.
What is the comparison operator for not equal?
!=
What is the comparison operator for greater than?
5>2
What is the comparison operator for smaller than?
2<5
What is the comparison operator for greater than or equal to?
5>=2
What is the comparison operator for smaller than or equal to?
2<=5
What are the three logical operators that are useful if we want to combine multiple conditions?
and, or, not
What does the “and” operator do?
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.
What does the “or” operator do?
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
What does the “not operator” do?
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.