0% found this document useful (0 votes)
5 views

python7

The document explains logical operators in Python, specifically Logical AND, OR, and NOT. It provides definitions, examples, and outputs for each operator, illustrating how they function with Boolean values. The summary emphasizes that AND returns True only if both values are true, OR returns True if at least one value is true, and NOT returns the opposite of the given value.

Uploaded by

Prachi More
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

python7

The document explains logical operators in Python, specifically Logical AND, OR, and NOT. It provides definitions, examples, and outputs for each operator, illustrating how they function with Boolean values. The summary emphasizes that AND returns True only if both values are true, OR returns True if at least one value is true, and NOT returns the opposite of the given value.

Uploaded by

Prachi More
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

7/27/24, 8:59 PM Revolutionizing the Job Market | NxtWave

https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=36b50c7e-806a-4834-859f-1c031bdf9942&s_id=3e422df5-… 1/5
7/27/24, 8:59 PM Revolutionizing the Job Market | NxtWave

Logical Operators
The logical operators are used to perform logical operations on Boolean
values.
Gives

True or False as the result.

Following are the logical operators

and

or

not

Logical AND Operator

Gives

True if both the booleans are true else, it gives False

Code
PYTHON

1 print(True and True)

Output

True

Examples of Logical AND

Code

PYTHON
1 i t((2 3) d (1 2))
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=36b50c7e-806a-4834-859f-1c031bdf9942&s_id=3e422df5-… 2/5
7/27/24, 8:59 PM Revolutionizing the Job Market | NxtWave
1 print((2 < 3) and (1 < 2))

Step by Step Explanation

(2 < 3) and (1 < 2)


True and (1 < 2)
True and True

Output

True

Logical OR Operator

Gives

True if any one of the booleans is true else, it gives False

Code
PYTHON

1 print(False or False)

Output

False

Examples of Logical OR

Code

PYTHON

https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=36b50c7e-806a-4834-859f-1c031bdf9942&s_id=3e422df5-… 3/5
7/27/24, 8:59 PM Revolutionizing the Job Market | NxtWave
1 print((2 < 3) or (2 < 1))

Step by Step Explanation

(2 < 3) or (2 < 1)
True or (2 < 1)
True or False

Output

True

Logical NOT Operator

Gives the opposite value of the given boolean.

Code
PYTHON

1 print(not(False))

Output

True

Examples of Logical NOT

Code

https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=36b50c7e-806a-4834-859f-1c031bdf9942&s_id=3e422df5-… 4/5
7/27/24, 8:59 PM Revolutionizing the Job Market | NxtWave

PYTHON

1 print(not(2 < 3))

Step by Step Explanation

not(2 < 3)
not(True)
False

Output

False

Summary

1. Logical AND Operator gives True if all the booleans are true.
2. Logical OR Operator gives True if any of the booleans are true.
3. Logical NOT Operator gives the opposite value

https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=36b50c7e-806a-4834-859f-1c031bdf9942&s_id=3e422df5-… 5/5

You might also like