Describe the difference between a chained conditional and a nested conditional. Give your own example of each.
In chained conditionals if/else/elif flow controls are indented , all to the same depth while no nesting between them whereas in nested conditionals the flow controls vary in depth.
The key distinct differentiator between nested and chained conditionals is nesting.
# Nested Conditional
def flow_if(due, overdue):
if overdue == True:
if due > 10000:
print('Amount is due!! ')
elif 10000 > due > 1000:
print('Target is met')
else:
print("Nest ")
else:
print("Late..")
# chained conditional
def flow_if(account):
if account > 10000:
print('Bye')
elif account < 0:
print('Less amount !!')
else:
print("No amount")
Comments
Leave a comment