Q. Relational Operators' practice: (Interactive mode)
x = 29.0, y = 13, z = 2, p = 0.5, q = 12.79, i = 13, j = 29.0, k = y – 11, a = ''(empty string), b = '', c = 'great', d = 'Great', e = 'GREAT', f = 'Great', g = 'GREAT', h = ' great'
| S. No. | Expression | Result | Reason |
|---|---|---|---|
| 1 | y > p * 26 | ||
| 2 | (y > p) * 26 | ||
| 3 | x <= y < x + y | ||
| 4 | x //y < p * 20 | ||
| 5 | x != y * z + 3 | ||
| 6 | x == y * z + 3 | ||
| 7 | x - 3 != y * 2 | ||
| 8 | x - (3 != y) * 2 | ||
| 9 | a == b | ||
| 10 | c == d | ||
| 11 | d == g | ||
| 12 | f == d | ||
| 13 | e == g | ||
| 14 | h == c |
Answer :-
| S. No. | Expression | Result | Reason |
|---|---|---|---|
| 1 | y > p * 26 | False | We should know the precedence order of operators. |
| 2 | (y > p) * 26 | 26 | (1{means True}) * 26 1 * 26 26 |
| 3 | x <= y < x + y | False | We should know the precedence order of operators. |
| 4 | x // y < p * 20 | True | Precedence order of ‘*’ and ‘//’ greater then ‘<’ operator. |
| 5 | x != y * z + 3 | False | Precedence order of ‘*’ and ‘+’ greater then ‘!=’ operator. |
| 6 | x == y * z+3 | True | Precedence order of ‘*’ and ‘+’ greater then ‘==’ operator. |
| 7 | x - 3 != y * 2 | False | Precedence order of ‘*’ and ‘-’ greater then ‘!=’ operator. |
| 8 | x - (3 != y) * 2 | 27.0 | Precedence order of ‘()’, ‘*’ and ‘-’ greater then ‘!=’ operator. |
| 9 | a == b | True | Both are empty string, So their id is same. |
| 10 | c == d | False | Both variables have different values look carefully. |
| 11 | d == g | False | Both variables have different values look carefully. |
| 12 | f == d | True | Both variables have same value so their id is same. |
| 13 | e == g | True | Both variables have same value so their id is same. |
| 14 | h == c | False | Both variables have different values look carefully. |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )