HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Logic Circuits, Logic Expressions and Truth Tables
  1. 1From a logic expression to a circuit and back
  2. 2Truth tables for three inputs
  3. 3From a problem statement or a truth table to a circuit
  1. Computer Science
  2. /Logic Circuits, Logic Expressions and Truth Tables
  3. /From a problem statement or a truth table to a circuit

Course 10.3·Lesson 3 of 3

From a problem statement or a truth table to a circuit

A problem in words can be turned into a logic expression, a circuit and a truth table. You learn which words point to which gate and how to place the brackets. Then you write an expression from a truth table, with one AND term for each row whose output is 1.

about 25 min1 simulation1 practice question
Lesson 3 of 3Show all lessonsHide
Logic Circuits, Logic Expressions and Truth Tables
  1. 1From a logic expression to a circuit and back
  2. 2Truth tables for three inputs
  3. 3From a problem statement or a truth table to a circuit

Try the code and the simulations beside the lesson.

From words to an expression

A greenhouse has a fan. The fan should switch on when it is hot and the window is not open, or when the air is damp.

  1. Give each condition a letter, and say what 1 means. T = 1 when it is hot. W = 1 when the window is open. H = 1 when the air is damp. The fan is X.
  2. Find the gate words. "and" is AND, "or" is OR, "not" is NOT. "Either ... but not both" is XOR, and "neither ... nor" is NOR.
  3. Group the phrases with brackets. "hot and the window is not open" is one group. The "or" joins that group to H.

The expression is X = (T AND (NOT W)) OR H.

A logic circuit drawn with the standard gate symbols. Inputs T, W and H are on the left and the output X is on the right. W goes into a NOT gate; T and the output of the NOT gate go into an AND gate; the output of the AND gate and H go into an OR gate, whose output is X.

The circuit has a NOT gate on W, an AND gate for the first group and an OR gate at the output. It is drawn exactly as the words say.

The fan is on in 5 of the 8 rows. Its output column, in the order T W H from 0 0 0 to 1 1 1, is 0, 1, 0, 1, 1, 1, 0, 1.

The same rule in pseudocode

Paper 2 also uses the words AND, OR and NOT in pseudocode, to join conditions. Here is the fan rule as Cambridge pseudocode. It is shown, not run: the site's code boxes run Python only.

pseudocode
IF (Hot = TRUE AND WindowOpen = FALSE) OR Damp = TRUE
  THEN
    FanOn ← TRUE
  ELSE
    FanOn ← FALSE
ENDIF

The runnable Python version of the same rule is in Try it in Python below.

From a truth table to an expression

Sometimes you are given only the table. Use the rows where the output is 1.

  1. One AND term for each row with X = 1. Write each input that is 1 as itself, and each input that is 0 with NOT.
  2. Join the terms with OR.

Take this table, with the rows in the usual order:

A B CX
0 0 00
0 0 10
0 1 00
0 1 11
1 0 00
1 0 11
1 1 00
1 1 11

X = 1 in the rows 0 1 1, 1 0 1 and 1 1 1. So:

X = ((NOT A) AND B AND C) OR (A AND (NOT B) AND C) OR (A AND B AND C)

Check: each term is 1 in its own row only, so the OR of the three is 1 in exactly those rows. Any expression with the same table is correct. Here a shorter one also works: X = C AND (A OR B). Test it on the table yourself.

For two inputs, the same method on the XOR column 0, 1, 1, 0 gives (A AND (NOT B)) OR ((NOT A) AND B), which you met in the last course.

Practise with new numbers

Try it in Python

The program writes the fan rule with Python's and, or and not ideas, and lists every row that switches the fan on.

Read it first. Then run it. How many rows switch the fan on?

1. Change the rule so the fan also needs the window shut when the air is damp. Write the new expression first.

2. Print fan(0, 1, 1). Explain the answer from the rule.

Common mistakes

  • No meaning for 1. Say what 1 means for each input before you start.
  • Brackets in the wrong place. Group the words that belong together, then join the groups.
  • "Or" that means "but not both". Read the problem: only "but not both" or "either one" with that meaning is XOR.
  • A term for a row with X = 0. Use only the rows with X = 1.

Remember these

  • Letter each condition and say what 1 means.
  • and is AND, or is OR, not is NOT, but not both is XOR, neither nor is NOR.
  • From a table: one AND term per row with X = 1, joined by OR.
  • Any expression with the same truth table is correct.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. A light comes on when a button is pressed (B = 1) and it is not daytime (D = 1 in daytime). Write the expression for the light L.
  1. A table with inputs A and B has X = 1 only in the row 1 0. Write an expression for X.
  1. A table has X = 1 in the rows 0 0 and 1 1 only. Write an expression for X.
  1. Which gate matches "the alarm sounds when neither door is open"?
  1. In the fan rule, the air is damp (H = 1). Can the fan be off?

References

  • Cambridge International, IGCSE Computer Science 0478 syllabus for 2026, 2027 and 2028, topic 10 Boolean logic and section 4 (logic gate symbols and pseudocode).

Enroll free in Logic Circuits, Logic Expressions and Truth Tables

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (4)

A lift moves (X = 1) when its door is shut (S = 1) and a button is pressed…Easy · High School (9–10) · by StemPy Lab
A logic analyser records X for every input pattern of A, B and C, from 0 0 0 up to 1 1 1: 0, 0, 0…Medium · High School (9–10) · by StemPy Lab
A water heater has a safety cut-out. The cut-out switches the heater off (X = 1) when the water is…Hard · High School (9–10) · by StemPy Lab
That was the last lessonBack to the course: take the test
← Logic Circuits, Logic Expressions and Truth Tables
← Truth tables for three inputsNext →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

A truth table with inputs A, B and C has the output column 0, 1, 0, 1, 0, 1, 0, 0 in the usual row…Hard · High School (9–10) · by StemPy Lab

Python Labs (1)

From a truth table to an expressionPython Lab · by StemPy Lab

Question Sets (1)

Circuits, Expressions and Truth Tables: Think It Through10 questions · by StemPy Lab

Notes (1)

Logic Circuits and Truth Tables: Quick RevisionNote · by StemPy Lab