Answer to Question #112519 in Python for Lebenis

Question #112519
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-04-28T12:27:27-0400
cat = 1 #variable for cat
dog= 0 #variable for dog

#the nested will be

if(cat==1):

  if(dog==0):
  
    print("cat is 1 and dog is 0")

#Examples of code
if(cat==1 and dog==0):

  print("cat is 1 and dog is 0")

#same result, less code

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