Answer to Question #274459 in Python for kika

Question #274459


Describe the difference between a chained conditional and a nested conditional. Give your own example of each. 


1
Expert's answer
2021-12-03T00:37:03-0500

Chained conditional is an if statement where a condition is executed if it is true but if it is false the next condition is checked and so on

Example

n=10
if n%2==0:
    print("Even number")
elif n%2!=0:
    print("Negative number")
else:

    print("Invalid number")

Nested condition is a condition where an if statement is created inside another if statement.

example

n=10
if n%2==0:
    if n>0:
        print("Positive even number")
else:
    if n<0:
        print("Negative even number") 

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