For the below Python expression:
3 % 3 * 14 == 18.2 / 8.1 and 3.1 + 15.7 * 19.1 >= 6.6 // 18 // 15.0
Solution:-
Precedence order of operators: * / % // , + - , >= , ==
Expression 1: 3 % 3 * 14 == 18.2 / 8.1
Firstly evaluating Left hand side 3 % 3 * 14 as % , * have same precedence so you evaluation will be done in Left to Right associativity order 3 % 3 * 14 = 0 * 14 = 0
Evaluating Right hand side 18.2 / 8.1 = 2.246
Clearly, LHS is not equal to RHS so it will return FALSE.
Expression 2: 3.1 + 15.7 * 19.1 >= 6.6 // 18 // 15.0
LHS: 3.1 + 15.7 * 19.1 = 3.1 + 299.87 = 302.97 (Because * has higher precedence than +)
RHS: 6.6 // 18 // 15.0 = 0.0 // 15.0 = 0.0
Clearly LHS >= RHS so it will return TRUE.
Get Answers For Free
Most questions answered within 1 hours.