Computer Applications
Differentiate between if and if-else statements.
Python Control Flow
35 Likes
Answer
Difference between if and if-else statements in Python:
| S. No. | if | if-else |
|---|---|---|
| 1. | if statement allows us to execute a code block when the condition is True. | if-else statement allows us to execute different code blocks based on whether the condition is True or False. |
| 2. | if statement does nothing in case condition evaluates to False. | if-else statement executes the statements indented below else when the condition is False. |
Answered By
15 Likes