Hello Dear Students
In this post, I am sharing important python expression evaluation question answers with valid reasons. These questions help you to understand the precedence of operators in python.
All the best.
Operator Precedence in Python
Operator Precedence :
Execution of the operator depends on the precedence of the operator.
Order | Operator | Description |
Highest | () | Parentheses |
↑ | ** | Exponentiation (right to left) |
| | ~ | Bitwise nor |
| | +, – | Unary plus and Minus |
| | *, /, //, % | Multiplication, Division, floor division, remainder |
| | +, – | Addition, Subtraction |
| | & | Bitwise and |
| | ^ | Bitwise XOR |
| | | | Bitwise OR |
| | <, <=, >, >=, <>, !=, ==, is, is not | Relational Operators, Identity Operators |
| | not | Boolean NOT |
↓ | and | Boolean AND |
Lowest | or | Boolean OR |
To study click Python Operator and Precedence
Evaluating Expression in Python Important Question Answer
Que 1: Consider the following expression:
51 + 4 – 3 ** 3 // 19 – 3
Which of the following will be the correct output if the expression is evaluated?
a. 50
b. 51
c. 52
d. 53
Que 2. What will the following expression be evaluated in Python?
print(6 * 3 / 4 ** 2 // 5 – 8 )
(a) -10
(b) 8.0
(c) 10.0
(d) -8.0
Que 3. What will the following expression be evaluated in Python? [CBSE 2021]
2 * 3 + 4 ** 2 – 5 // 2
(a) 45
(b) 20
(c) 22
(d) 8
Que 4. What will the following expression be evaluated in Python? [CBSE 2021]
6 < 12 and not (20 > 15) or (10 > 5)
(a) True
(b) False
(c) and
(d) not
Que 5. What will the following expression be evaluated to in Python? [CBSE SQP 2022-23]
print(15.0 / 4 + (8 + 3.0))
(a) 14.75
(b) 14.0
(c) 15
(d) 15.5
Que 6. Evaluate the following expression and identify the correct answer. [CBSE SQP 2021-22]
16 – (4 + 2) * 5 + 2**3 * 4
(a) 54
(b) 46
(c) 18
(d) 32
Que 7. What will the following expression be evaluated in Python? [CBSE 2021]
10 > 5 and 7 > 12 or not 18 > 3
(a) True
(b) False
(c) or
(d) and