Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Logic operators: How to create complex logical propositions

Learn programming basics! Understand algorithms, propositional logic, and Python syntax. Create programs and grasp the basics of computer science.

In this video we consider logic operators. The figure below shows a visual representation of how computers make decisions using logical propositions.

The black dot at the top indicates the starting point/flow of the program. Then there is a diamond which indicates a conditional. This is where the program will evaluate a logical expression to determine its truth (is it True or False?). If the condition (A) is True, then the program will follow the branch on the left and do (B). If the condition (A) is False, then the program will follow the branch on the right and do (C).

As a result, a program can do different things, depending on a condition. For example, your program may express as (A) the condition “if the window is open, and it’s raining” and your program will “close the window” as action (B) or “open the window” as action (C). Logical propositions are concerned with the condition (A).

IF (A = TRUE), Then B, Else C, End IF

We said that a logical proposition is an expression that can either be True or False, but can’t be both True and False. These expressions will usually express some truth about an event. For example, “is it raining outside” is a logical proposition which can either be True or False ( True if indeed it is raining outside or False if not).

We also said that we can create complex logic propositions using connectives (aka logical operators): AND, OR and NOT. There are more connectives than this, but in this course we focus on the very basic ones. In the next step we’ll revisit each one.

This article is from the free online

An Introduction to Programming Using Python

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now