Answer to Question #112852 in Python for Joshua Oluwabusayo Obong

Question #112852
Describe the difference between a chained conditional and a nested conditional. Describe a strategy to avoid nested conditions. Give an example of a nested conditional that can be changed to a single conditional, and show the equivalent unique conditional
1
Expert's answer
2020-05-01T14:44:37-0400
a = 1
b = 2
if a == 1:
    if b == 2: #It will only be executed if a = 1
        print('Yes')

if a == 1 and b == 2:
    print('Yes') #It will only be executed if (a = 1 AND b = 2)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS