Monday, 24 June 2019

Logical Operators

#Find the given year is Leap year or not?

year=int(input("enter any year to be checked "))
if((year%4==0)and (year%100!=0) or (year%400==0)):
    print("Leap year")
else:
    print("Not a leap year")

"""output
enter any year to be checked 2004
Leap year
>>>
=================== RESTART: F:/Programs/Operator/leap.py ===================
enter any year to be checked 2005
Not a leap year
>>>
=================== RESTART: F:/Programs/Operator/leap.py ===================
enter any year to be checked 2100
Not a leap year
"""

Logical Operators:

These operators are used to perform logical operations on the given expressions. i.e used to construct compound conditions. A compound condition is a combination of more than one simple condition. Each condition is evaluated True or False.
Operators are:
and,or ,not

andàIf both expressions/condition/argument is True then the only result is True. False otherwise

oràIf at least one condition/expression/argument is True then the result is True

notàif any condition/expression/argument is True then the result is false

The video will be live at: https://youtu.be/SQxypOkKWyM Next Topic: Non Boolean logical operators
Previous TopicRelational Operator



No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...