Python Conditional Statement
title: “Python Conditional Statement” categories:
- Tutorial classes: wide tags:
- machine-learning
- python
- programming
-
learning
Conditional Statement
A conditional statement is needed in programming to check on some condition or logical decision. e.g., if you are python than print “hello python”.
So, there are certain type of conditional statement:
- if statement
- if else statement
- if elif else statement
If Statement
This is the most basic form of logic introduced into the program. Like I exampled in above example. If true then do this.
If else Statement
You can say this is the advance version of if statement. In previous if the condition is false it does nothing. While in this if else statement, if the condition goes wrong then you can write some statement. e.g., if you are python print “Hello python” else print “Who are you?”.
If elif else Statement
This statement if more advance version. In this, we can tie up many if and else condition. We can say nested if else. e.g., if you are python print “Hello python” elif you are java print “Hello java” else print “Who are you?”.
You can nest as many elif as you want.
So, that covers the basic of conditional statements in python.
So be connected. Thanks for visiting. Share this with your friends.
Comment your suggestions.
Leave a comment