Thursday, 28 September 2017

7)Python if.elif.else Statements

Python if.elif.else Statements

The if…elif…else statement is used in Python for decision making.

i)if Statement:
Syntax:
if test expression:
    statement(s)
if Statement Flowchart:


Example:
x = 10
if x > 0:
    print(x,"is positive numner")

ii)if...else Statement
Syntax:
if test expression:
    Body of if
else:
    Body of else
if...else Statement Flowchart:

Example:
x = 10
if x > 0:
    print(x,"is positive numner")
else:
    print(x,"is either zero or negative number")

iii)if...elif...else statement:

Syntax:
if test expression:
    Body of if
elif test expression:
    Body of elif
else:
    Body of else
if...elif...else Flowchart:




Example:
x = 10
if x > 0:
    print(x,"is positive numner")
elif x < 0:
    print(x,"is negative number")
else:
    print(x,"is zero")






8 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Simply wish to say your article is as astonishing. The clarity in your post is simply great, and I could assume you are an expert on this subject. Well with your permission let me grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the gratifying work.
    Surya Informatics

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thank you for this informative and helpful article. It really gave me a lot of information, hope that you’ll continue to create articles like this.

    Best data science training institute in marathahalli
    Spark Training in Marathahalli

    ReplyDelete
  5. Nice blog,Very useful article,Thanks for sharing this information.
    Spark Scala Online Training

    ReplyDelete

Fundamentals of Python programming

Fundamentals of Python programming: Following below are the fundamental constructs of Python programming: Python Data types Python...