Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Section 4.7 - Nested if and Multi-Way if-elif-else Statements - Check Point - MyProgrammingLab - Page 104: 4.11

Answer

For x=3 and y=2 : x is 3 For x=3 and y=4 : z is 7 For x=2 and y=2 : No Output

Work Step by Step

For x=3 and y=2: The condition for the first if statement will be true because x>2 but the condition for the nested if statement will be false as y is not less than 2, so the control will go to the else statement and "x is 3" will be printed. For x=3 and y=4: The condition for the first if statement will be true because x>2 so the control will go inside and the condition for the nested if statement will also be true as y>2, then z will be calculated as x+y and after that the value of z will be printed as "z is 7" For x=2 and y=2: The condition for the first if statement will be false as x>2 is false hence the control will not go inside and since there is nothing after this if statement the program will end with no output.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.