closed - book, closed - note, closed - person.\n1. list all the comparison/relational operators. hint: there…

closed - book, closed - note, closed - person.\n1. list all the comparison/relational operators. hint: there are more than 4.\n2. complete the following truth tables for the boolean logic operators:\n| x | not x |\n| false | |\n| true | |\n| x | y | x and y |\n| false | false | |\n| false | true | |\n| true | false | |\n| true | true | |\n| x | y | x or y |\n| false | false | |\n| false | true | |\n| true | false | |\n| true | true | |\nfor question 3, assume:\na = 3.5\nb = 10\n10 is not 0\n3. evaluate the following expressions:\ni) a > b or b!= 0 → true\nii) not (b < a) and a <= 3.5 → false\nb 10 is not less than 3.5\ncontinued on back...
Answer
Explanation:
Step1: List comparison/relational operators
The common comparison/relational operators are: == (equal to), != (not equal to), < (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to).
Step2: Complete 'not' truth - table
The 'not' operator negates the boolean value. So when x = False, not x = True; when x = True, not x = False.
Step3: Complete 'and' truth - table
The 'and' operator returns True only when both operands are True. So:
False and False = FalseFalse and True = FalseTrue and False = FalseTrue and True = True
Step4: Complete 'or' truth - table
The 'or' operator returns True if at least one of the operands is True. So:
False or False = FalseFalse or True = TrueTrue or False = TrueTrue or True = True
Step5: Evaluate expressions
i)
Given a = 3.5 and b = 10, a > b is False and b != 0 is True. In an 'or' operation, if one of the operands is True, the result is True. So a > b or b != 0 is True.
ii)
b < a is False, so not (b < a) is True. And a <= 3.5 is True since a = 3.5. In an 'and' operation, both operands must be True for the result to be True. So not (b < a) and a <= 3.5 is True.
Answer:
==,!=,<,>,<=,>=
| x | not x |
|---|---|
| False | True |
| True | False |
| x | y | x and y |
|---|---|---|
| False | False | False |
| False | True | False |
| True | False | False |
| True | True | True |
| x | y | x or y |
|---|---|---|
| False | False | False |
| False | True | True |
| True | False | True |
| True | True | True |
i) True ii) True