Q. Consider the Python program below:
x = int (input ("Enter a value for x: "))
y = int (input ("Enter a value for y: "))
z = int (input ("Enter a value for z: "))
if x < y < z:
print ("branch 1", end = "")
elif x > y > z:
print ("branch 2", end = '')
else:
print ("branch 3", end = '')
print (" is the branch")
What do you think is printed by the if statement under each scenario below?
(a) | The user enters: 0 for x; 1 for y, and 1 for z | |
(b) | The user enters:- 1 for x 50 for y, and 100 for z | |
(c) | The user enters: 10 for x; 50 for y, and 15 for z | |
(d) | The user enters:- 1 for x; -50 for y, and -100 for z |
Answer :-
(a) | The user enters: 0 for x; 1 for y, and 1 for z | Output :-branch 3 is the branch |
(b) | The user enters:- 1 for x 50 for y, and 100 for z | Output :-branch 1 is the branch |
(c) | The user enters: 10 for x; 50 for y, and 15 for z | Output :-branch 3 is the branch |
(d) | The user enters:- 1 for x; -50 for y, and -100 for z | Output :-branch 2 is the branch |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )