Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Truth Table for AND
Expression1 AND Expression2
Operand1
False
False
True
True
Operand2
False
True
False
True
Result
False
False
False
True
Operand2
False
True
False
True
Result
False
True
True
True
Truth Table for OR
Operand1
False
False
True
True
Truth Table for NOT/<>
Input
0/False
1/True
Result
1/True
0/False
What is Operator Precedence?
Operator precedence determines the order in which operators
are evaluated. Operators with higher precedence are evaluated
first. A common example: 3 + 4 * 5 // returns 23. The
multiplication operator (" * ") has higher precedence than the
addition operator (" + ") and thus will be evaluated first.
Logical Operator Precedence Order
1. NOT
2. AND
3. OR
What is Boolean Expression?
A boolean expression is an expression that results in a boolean value, that is, in a value
of either true or false.
Solve the following Boolean Expressions:
If P = -100, Q = 20, X = 50, Y = -25, Z = 100, C = True
1. X > 1 AND X < 100 OR Q = 300
2. P > -20 OR X <= 50
3. Q >= 30 AND Y< -30
4. Z >= 99 OR Y >= 1
5. P = -100 AND NOT C
6. What is an Array?
- An array variable is used to store multiple values in a single variable.
If x=2 and y =3 Prove that (x+y)2 = 25
(2+3)2 = 25
(2+3)2 = 25
(5)2 = 25
5*5 = 25
25 = 25
LHS = RHS
Let’s Say X = 20, y = 10
X>10 AND y>=20
=>20>10 AND 10>=20
=>True AND False
=>False
If X>10 AND y>=20 Then
Print “Raining”
Else
Print “Sunny”
End IF
Let’s Say X = 100, y = 50 , Z = -5
X>=100 AND Z <-100 OR X>10
=>100>=100 AND -5<-100 OR 100>10
=>True AND False OR True
=>False OR True
=>True
If P = -100, Q = 20, X = 50, Y = -25, Z = 100, C = True
1. X > 1 AND X < 100 OR Q = 300
=>50>1 AND 50<100 OR 20=300
=>True AND True OR False
=>True OR False
=>True
If P = -100, Q = 20, X = 50, Y = -25, Z = 100, C = True
P > -20 OR X <= 50
=>-100>-20 OR 50<=50
=>False OR True
=>True
If P = -100, Q = 20, X = 50, Y = -25, Z = 100, C = True
Q >= 30 AND Y< -30
=>20>=30 AND -25<-30
=>False AND False
=>False
If P = -100, Q = 20, X = 50, Y = -25, Z = 100, C = True
Z >= 99 OR Y >= 1
=>100>=99 OR -25>=1
=>True OR False
=>True
If P = -100, Q = 20, X = 50, Y = -25, Z = 100, C = True
P = -100 AND NOT C
=>-100 = -100 AND NOT True
=>True AND False
=> False