Preview

04 - Arithmetic and Boolean Operators

 1. There are several arithmetic operators shown below. Fill in the blanks on line 3 and line 5.
+	Addition e.g. x=6+5 gives 11
-	Subtraction e.g. x=6-5 gives 1
___	Multiplication e.g. x=12*2 gives 24
/	Division e.g. x=12/2 gives 6
MOD	Modulus e.g. 12MOD5 gives ______

  Line 3: x Line 5: 0

  Line 3: x Line 5: 2

  Line 3: * Line 5: 0

  Line 3: * Line 5: 2

 2. During programming you will also find that COMPARISON operators are of great importance. A list of comparison operators are shown below. Fill in the blank on line 2.
==	Equal to
!=	____________
<	Less than
<=	Less than or equal to
>	Greater than
>=	Greater than or equal to

  This is an operator which means: "definitely equal to"

  This is an operator which means: "incorrect data type"

  This is an operator which means: "not equal to"

  This is an operator which means: "do not compare"

 3. Two additional arithmetic operators are shown below. "DIV" and "^".Fill in the blanks on line 1 and line 2.
DIV	Quotient e.g. 17DIV5 gives _____
^	___________ e.g. 3^4 gives 81

  3 / Duplicate the number

  2 / Opposite of Division

  3 / Exponentiation

  0 / Double Multiplication

 4. Expressions that are constructed with _______ operators such as AND, OR , and ______ will result in either True or False.

  Comparison / Boolean

  Boolean / Not

  Arithmetic / Opposite

  Arithmetic / Not

 5. The symbols below are used to denote 'not' 'and' and 'or' operators. Can you fill in the blanks (?) to indicate which symbol means what?
uploads/bo.png

  1. OR 2. AND 3. NOT

  1. AND 2. OR 3. NOT

  1. NOT 2. OR 3. AND

  1. OR 2. NOT 3. AND

 6. Analyse the tables and sentence below. Can you fill in the blanks?
uploads/boolean_not_not_true.png

  True / False

  Not / True

  False / True

  True / Not

 7. The following code will fail to run. Can you explain why?

  Line 1 should be score=10 and Line 2 should be if score==10:

  There is no error, the assignment and comparison operators are used correctly

  Line 1 should be score===10 and Line 2 should be if score=10:

  Line 1 should be score==10 and Line 2 shoudl also be if score==10:

 8. Analyse the statement below. What will the output be?
5 is not equal to 9 so the following statement will output ____

>>> 5 != 9

____

  False

  True

  Error

  Not

 9. Evaluate the Boolean expressions and fill in the blanks.
uploads/evalutebooleanex_t_t_t.png

  False True False

  True True True

  True True False

  False False True

 10. Evaluate the Boolean expression and fill in the blanks
uploads/evalutebooleanex_t_f_f.png

  False / True / True

  True / True / False

  True / False / False

  True / False / True