Computer Science, asked by omargurd, 10 months ago

Compare and contrast if-else and elif statements. Give examples.

Answers

Answered by Anonymous
3

Explanation:

to choose between elif and else you have to decide if you need another condition checked before executing code. elif is essentially an else block with a new if statement inside it.

elif - use if you have another condition to check

else - use if you want code to execute without another condition checked

Answered by adhvaith2007
1

Answer: The first form if-if-if tests all conditions, whereas the second if-elif-else tests only as many as needed: if it finds one condition that is True , it stops and doesn't evaluate the rest. In other words: if-elif-else is used when the conditions are mutually exclusive.

Explanation:

Similar questions