Answer to Question #240288 in Python for jack

Question #240288

Describe the difference between a chained conditional and a nested conditional. Give your own example of each. Do not copy examples from the textbook.

1
Expert's answer
2021-09-21T13:56:54-0400
x, y = 1, 0
#chained conditional
if x > y:
	print('x bigger than y')
elif y > x:
	print('y bigger than x')
else:
	print('x = y')
#nested conditional
if x > y:
	print('x bigger than y')
else:
	if y > x:
		print('y bigger than x')
	else:
		print('x = y')

The difference between a chain of conditions and nested conditions is that only one condition is fulfilled in the chain of conditions, and the chain of conditions is branching and several conditions can be fulfilled.


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