Nested if-else Conditional Statement in python

General Form of if- elif-else Conditional Statement:

In this statement, I discussed nested if-else in python.

The general form of if-elif-else statement is as follows:

if < conditional >:
<Sequence S1, of statements to be executed >
elif < condition2 >:
< Sequence S2 of statements to be executed >
elif < condition3 >:

<Sequence S3, of statements to be executed >





<Sequence Sn of statements to be executed >

In the above description, elif is an abbreviation used in Python for else if. By now, it must be clear that the clauses elif and else of the if statement is optional, and that the sequence of statements defined under a clause is executed in a sequence. As the physical alignment of statements determines which statements form a block of code, one needs to be very careful about indentation while writing Python programs.

if elif else python Conditional Statement:

Sometimes, we need a control structure within another control structure. Such a mechanism is called nesting. For example, the function maximum3 Fig.2 ) finds the maximum of three numbers using nested structure. Here, and if clause has been used within another if clause. First, we test whether n1 is greater than n2. If so, the condition n1 n3 is evaluated, and if True, n1 is declared as the maximum number. The other cases are dealt with similarly.

complete this article at this link




I am web developer. I am student of cs and it.I like programming language like c c++ and python.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A quick and thorough guide to ‘null’: what it is, and how you should use it

How to do better deployments of spark batch jobs to AWS EMR using Apache Livy

Scalability : Twitter’s Journey

Improving performance using distributed cache with Couchbase


ORIGINAL PRODUCT 2 Stück Reoben BL1860B 18V 5.5Ah Lithium Akku Ersatzakku für Makita BL186

The Seven Pillars of a Successful Cloud Environment: Security

Monoids are Composable List Summarizers

Java RegEx: Part 7— Boundary Matcher

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kamran Abbasi

Kamran Abbasi

I am web developer. I am student of cs and it.I like programming language like c c++ and python.

More from Medium

What is Numpy and why we use it instead of python’s Built-in Lists?

#1.2 Installing a Code Editor (IDE) — Python for Beginners

A red Python looking into the camera

How to do Matrix Multiplication in Python — Codewars

How Python Evolved as a Programming Language