Friday , July 21 2017
Home / Python / Python if statement Example

Python if statement Example

The Python if statement is also similar like java, php simple if statements and etc.,

Python if statement :

Python if is a simple conditional statement which executes the block of statements if the condition returns True otherwise it skips the execution of the block.

Syntax :


if condition : statement

Or

if condition :

    statement 1

    statement 2

Example :


name = input('Enter your name .. ')
if name == 'chandra' :
    print('Hi',name)

print('Hello')

$ python3 sample.py
Enter your name ..chandra
Hi chandra
Hello
$ python3 sample.py
Enter your name ..shekhar
Hello

 

Happy Learning 🙂

About chandrashekhar

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Recommended

Python Number Systems Example

According to the mathematics we have 4 types of number systems which are representing the …

Leave a Reply

Your email address will not be published. Required fields are marked *