Python elif Statement with AND Operator | Example code

Let’ see how to use AND operator to combine two basic conditional expressions in the boolean expression of the Python elif condition statement.

Example elif Statement with AND Operator in Python

Simple python example code.

mark = 50

if mark < 40:
    print('Failed')

elif 40 < mark < 80 and mark < 90:
    print('A+')

elif 80 < mark < 101:
    print('A++')

Output:

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.