video

Lesson video

In progress...

Loading...

Hello and welcome to Computing.

My name is Mrs. Holborow.

I'm so pleased you've decided to join me for the lesson today.

In today's lesson, we'll be exploring logic statements and how we can evaluate logic statements using Boolean logic.

Welcome to today's lesson from the unit Boolean logic.

This lesson is called Logic statements and expressions, and by the end of today's lesson, you'll be able to evaluate and develop logic statements using Boolean logic.

Shall we make a start? We will be exploring these keywords during today's lesson.

Boolean.

Boolean, a data type that can have one of two possible values, 0, false, or 1, true.

Logic statement.

Logic statement, an expression that is either true or false.

Logic expression.

Logic expression, a combination of logical operators and variables that is either true or false.

There are two main parts to today's lesson.

We'll start by evaluating logic statements and then we'll move on to develop logic statements using Boolean logic.

Let's make a start by evaluating logic statements.

Sofia has a statement, "If you study drama or are in the orchestra, you need to go to the play rehearsal this afternoon." This sentence can be written as a logic statement.

Rehearsal is equal to drama OR orchestra.

To evaluate a logic statement, substitute in the value of each Boolean variable, then evaluate the statement using the rules of the logical operator.

Aisha says here, "I don't act, but I play the tuba." So if we look at each Boolean variable for this statement, drama is equal to false because Aisha doesn't act, orchestra is equal to true because she plays the tuba.

And then if we look at the statement overall, rehearsal was an OR, so we have false OR true.

And because this is an OR statement, one or more values need to be true to return true, then the value of rehearsal is true.

So remember to substitute in the value of each Boolean variable and then evaluate the operator.

Andeep says, "I don't play an instrument or act." Let's have a look at the Boolean variables.

This time, drama is equal to false and orchestra is equal to false, which means then if we look at rehearsal, we've got false OR false, which will return as false.

So Andeep doesn't have to attend the rehearsal.

Time to check your understanding.

Jun studies drama and plays the violin.

So for him, the statement rehearsal is equal to drama OR orchestra is either true or false.

Pause the video here whilst you have a think.

That's right, it's true, but why is it true? It's true because if we look at the Boolean values, drama is equal to true and orchestra is equal to true, so then rehearsal is equal to true or true.

And remember, an OR statement is true if one or both values are true, so rehearsal is equal to true.

Logic statements are not always based on full sentences or real-life scenarios like we've seen so far this lesson.

Sometimes they're written as letters.

So here's some examples.

X is equal to NOT C, Y is equal to A OR brackets NOT B, Z is equal to A AND B.

The process we follow is exactly the same though.

So we evaluate the logic expression by substituting in the values of the inputs.

For example, we've been told that A is equal to true, B is equal to false, and C is equal to true.

So, if we have a look, we've got X is equal to NOT C.

We're going to substitute in the value of C to true.

So X is not true, which means that X is false.

Let's look at another example.

This example is a little bit more complicated because it includes brackets.

If there is more than one operator, remember to evaluate any part of the logic expression in brackets first.

So our values A, B, and C remain the same, but this time our statement is Y is equal to A or NOT B in brackets.

So we're going to look at the brackets first.

So the brackets mean NOT false, because B is set to false.

So now Y is equal to true or NOT false, which means Y is equal to true OR true, which means Y results in true.

Let's check your understanding.

We have a logic statement here which is Z is equal to A AND B.

If A is equal to true and B is equal to false, then Z is equal to, A, true, because A is true; B, false, because B is false; C, true, because AND only needs one input to be true; or D, false, because A and B both need to be the same? Pause the video here whilst you have a think.

Did you select B? Well done.

B is the correct answer because Z would be equal to false.

Remember, this is an AND statement, so in order to return true, both inputs need to be true.

You're doing a great job so far, so well done.

We're going to move on to our first task of today's lesson, Task A.

I'd like you to evaluate the following logic statements with the inputs A equals false, B equals false, and C equals true.

So the logic statements are P is equal to A OR C, Q is equal to NOT A in brackets AND NOT B in brackets, R is equal to A AND B in brackets OR C, and S is equal to NOT A or B in brackets.

Pause the video here whilst you complete the activity.

How did you get on? Great work.

Let's have a look at the answers together.

So here's the first two.

The first logic statement you were given was P is equal to A OR C.

So this means P is equal to false OR true, and because this is an OR, that means P is equal to true.

The second one was Q is equal to NOT A in brackets and NOT B in brackets.

So if we have a look at that, we've got NOT false in brackets and NOT false in brackets, which then means we've got true AND true, which means that Q is also equal to true.

And the next two, R is equal to A AND B in brackets OR C.

So that means R is equal to false AND false in brackets OR true, which means we've then got false OR true, which means that R is equal to true.

And then the last one was S is equal to NOT A or B in brackets.

So that's S is equal to NOT false OR false in brackets, so S is NOT false, which means S is true too.

Remember, if you need to go back through and make any corrections, you can always pause your video here and do that.

We're now going to move on to the second part of today's lesson, where we're going to develop logic statements using Boolean logic.

Andeep has a sentence here.

"If I have money and I do not have homework, I will go shopping." This sentence uses Boolean variables, things that can be either true or false.

Andeep could have money, he couldn't have money, he may have homework, he may not have homework.

So whether you have money is either true or false, and whether you have homework is either true or false too.

You can write a logic statement that can be used to calculate whether the outcome is true or false.

To write a logic statement, you need to follow these steps: identify and label the inputs and the outcome, identify the logical operators, and then remove the rest of the words! So let's start by identifying and label the inputs and the outcome in this sentence.

So, if I have money, we've labelled that as an input and we've given it the letter M.

And I don't have homework, so we've labelled that as an input and we've given it the letter H.

Then I will go shopping.

So there's the outcome, and we've labelled that as S.

Now we have to identify the logical operators.

If I have money AND, there's a logical operator, I do NOT, there's our second one, have homework, I will go shopping.

So AND and NOT are the logical operators in this sentence.

Then we just remove the rest of the words and we're left with this.

So the logic statement for whether Andeep goes shopping is S is equal to M AND NOT H.

Jun says, "I wrote down S is equal to NOT H AND M.

Is that wrong?" Maybe pause your video here and have a think.

Jun is also correct.

It does not matter which way round you write the inputs.

A and B is the same as B and A.

So here we have Jun's logic statement, S is equal to NOT H AND M.

Sofia looks a bit worried.

She says, "In Jun's version, is it NOT H AND M or is it just NOT H?" Maybe pause the video and have a think.

The NOT only applies to H, as it represents not having homework.

To make the logical expression clearer, you could use brackets here.

So you can see we've got S is equal to NOT H inside brackets AND M.

Time to check your understanding.

Label the input or inputs for this sentence.

If I am not too hot, I wear a jumper.

Is it A, hot, H; B, jumper, J; or C, hot and jumper? Pause the video here whilst you have a think.

That's correct.

A, hot, is the input for this sentence.

Jumper is the outcome.

Label the inputs or inputs for this sentence.

I will go to the park if my friend is not busy, and it is sunny.

Is it A, park and sunny, P and S; B, busy, B; C, sunny, S; or D, busy, B, and sunny, S? Pause the video here whilst you have a think.

That's right.

This sentence has two inputs, B and S, busy and sunny.

I will go to the park if my friend is not busy, and it is sunny.

The park is the outcome in this sentence.

You're doing a great job so far, so well done.

We're now moving on to our final set of tasks for today's lesson, Task B.

I'd like you to write a logic statement for each sentence.

So number one is if I am not too hot, I wear a jumper.

Number two is I will go to the park if my friend is not busy, and it is sunny.

Three is my cat is happy if you pat his head or stroke him.

Four, if the house is cold, either the door is open or the heating is not on.

And five, for combustion, you need oxygen, heat, and fuel.

Pause the video here whilst you complete the activities.

How did you get on with your logic statements? Great work.

Let's have a look at the answers together.

So for number one, the sentence was, if I'm not too hot, I wear a jumper.

So, we've labelled the inputs and outputs.

So hot is the input and J or jumper is the output.

And then we've identified the logical operator, which is NOT.

So J is equal to NOT H.

Sentence for number two was I will go to the park if my friend is not busy, and it is sunny.

So this answer should be P is equal to NOT B AND S.

Remember, you could put brackets around the NOT B if you wanted to.

For three, the sentence was my cat is happy if you pat his head or stroke him.

So the answer here is H for happy is equal to P for pat OR S for stroke.

Part four, if the house is cold, either the door is open or the heating is not on.

So the answer for this one is C is equal to D OR NOT H.

And then the last one, part five, for combustion, you need oxygen, heat, and fuel.

Now, notice here we've got a comma.

So the comma implies that all of the variables are needed, so oxygen and heat and fuel.

So the correct answer here is C is equal to O AND H AND F.

Remember, if you need to make any corrections, you can pause the video here and look back through your answers.

We've come to the end of today's lesson, and you have done a fantastic job, so well done.

Let's summarise what we have learnt in today's lesson.

Boolean variables are things that can be true or false.

For example, it is raining or I am hot.

You can write a logic statement to represent an outcome where the result is dependent on Boolean variables.

If you know the values of the variables, you can evaluate a logic statement to find out if the statement itself is true or false.

I hope you'll join me again soon.

Bye!.