Back to Course

Introduction to Python

0% Complete
0/0 Steps
  1. Python: Basics
    15 Quizzes
  2. Python: Control Flow
    12 Quizzes
  3. Python: Errors
    5 Quizzes
Lesson 2, Topic 7
In Progress

Python: Boolean Operator Or

Yasin Cakal 17 Oct 2021
Lesson Progress
0% Complete

The boolean operator or combines two expressions into a single larger expression that evaluates to True if either component evaluates to True.

Let’s take a look at an example:

2*2==4 or 2/2==4

This statement is made up of two expressions: 2*2==4 which is True and 2/2==4 which is False. Because the or operator connects the two expressions, the entire statement is True. For an or statement to be True, only one component must be True.

In English, the preposition or implies that if one component is True, the other must be False. In Python, this is not true. If both components of an or statement are True, the statement is also True.

Consider the following examples:

print(True or True)
print(True or False)
print(False or True)
print(False or False)



Notably, each or statement that contains at least one True component is True; however, the final statement contains two False components and is thus False.

%d bloggers like this: