What gets printed with the following code ?
x = True
y = False
z = False
if x or y and z :
print "yes"
else:
print "no
Answers
Answer:
yes is the output....
Explanation:
when comes true or false...and false we would take as false
"No" will get printed
Explanation:
We must understand the following so that, it will be easy to predict the output:
1. "and" operator returns true only when all the operands are true
True "and" false returns false
False "and" True returns false
False "and"False returns false
True "and" True returns true
2. "or" operator returns true if either one of the input is true.
True "or" false returns True
False "or" True returns True
False "or" False returns false
True "or" True returns true
Analyzing the code snippet,
if x or y and z: can be rewritten as if True or False and False
Note: Logical operator precedence is left to right
Step 1: if True or False => returns false, so once again the statement should be rewritten as
Step 2: if True and False=> returns false. Hence else statement gets executed and "no" is printed.
To Know More:
https://brainly.in/question/2427275
What is a logical operator
https://brainly.in/question/5900936
Find the difference between logical and relational operator.