Computer Science, asked by akshaya3004, 6 months ago

difeerence between if and elif in python​

Answers

Answered by dsp235803
2

Explanation:

if tests all conditions,

whereas the elif 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.

Answered by shubham4444singh
4

if

If statements are control flow statements which helps us to run a particular code only when a certain condition is satisfied. For example, you want to print a message on the screen only when a condition is true then you can use if statement to accomplish this in programming.

elif

The elif statement allows you to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE. Similar to the else, the elif statement is optional.

Similar questions