Evaluate the following expressions:
a) 6 * 3 + 4**2 // 5 – 8
b) 10 > 5 and 7 > 12 or not 18 > 3
2
Answers
Answer:
Evaluate the following expressions:
10 > 5 and 7 > 12 or not 18 > 3
Explanation:
10>5 = True
7>12 = False
18>13 = True
Now, T AND F or NOT True
T AND F = F, NOT True= F
Then, F or F=F
MILTAN PRABHAKARAN M , PEM SCHOOL OF EXCELLENCE....
ANY DOUBTS JUST CALL ME :919486283004
Answer:
The correct answers for the given expressions is found to be as follows:
(a) 13
(b) False
Explanation:
For (a) part:
We are given the expression:
We will solve this by the order of precedence of operators in python, which is as follows:
Exponentiation (**) followed by Complement (~), then Multiplication (*)/Division (/)/Floor Division (//)/Modulus (%) and lastly Addition (+)/Subtraction (-) followed by Bitwise, Comparison and logical operators.
Following this and simplifying, we get:
or we can say:
Thus, the given expression's simplification gives us the value of 13.
For (b) part:
We are given the expression:
Now, we know that the operators used are Logical operators and the comparison operators.
Comparison operators have a higher precedence and gives an output of either True or False.
Thus, simplifying the Comparison operators, we get:
Now, resolving the logical operators, we get:
Thus, the given expression bears the value of False.
#SPJ3