[go: up one dir, main page]

DEV Community

Cover image for Overview of conditions in python.
Keshav Jindal
Keshav Jindal

Posted on

Overview of conditions in python.

1.Introduction
Conditions in python helps us in many ways as they are the block of code in which we can specify some condition in the code to be performed.
2.If
The if statement shows a code for a decision making statement. 'if' is the keyword and ended by ':' at the end.
syntax
Image description
The output for above example is
Image description
3.Elif
The elif condition means that if the previous condition is not satisfied then elif statement will be checked. The 'elif' is the keyword and ended by colon.
syntax
Image description

The output for above example is
Image description
4.Else
The else statement means that if the 'if' or 'elif' statement is not true then this will be correct.
Image description
The output for above example is
Image description

Top comments (3)

Collapse
 
riju_bro profile image
riju_bro • Edited

Good for beginners.

Collapse
 
andrewbaisden profile image
Andrew Baisden

Good intro for a Python beginner.

Collapse
 
nilesh_jindal_85ed2091da1 profile image
Nilesh Jindal

Good work.