What value will be assigned to the x variable?
z = 0 y = 10 x = y < z and z > y or y < z and z < y
- 0
- True
- False
- 1
Explanation: Let’s analyze the example:
- 0 is assigned to z, and 10 is assigned to y,
- the result of the following evaluation
y < z and z > y or y < z and z < y
is assigned to x: - y < z evaluates to False,
- z > y evaluates to False,
- y < z evaluates to False again,
- and z < y evaluates to True.
- And now: False and False is False; False or False is False; and finally False and True is False.
More Questions: Python Essentials 1 (PE1) Course Final Test
Please login or Register to submit your answer