Preview

05 - Relational and Assignment operators

 1. Read the following excerpt and definition of operators and fill in the blanks.
Operators are special _________in Python that carry out arithmetic or 
logical computation. The value that the operator operates on is called 
the ________

  signs / opulents

  symbols / operand

  symbols / operation

  addition signs / operation

 2. The '+' operator performs

  multiplication

  subtraction

  division

  addition

 3. The '*' operator performs both subtraction and multiplication

  TRUE

  FALSE

 4. Analyse the code below which uses the '/' divide operator. What is the output?
x=5
y=2
z=x/y
print(z) #this is also called Division (float)

  3.5

  2.5

  3

  2

 5. The Division(floor) operator which is a // acts differently from a single /. What is the output here?
  x=5
  y=2
  z=x//y
  print(z)

  3

  

  2

  2.5

 6. __________returns the remainder when first operand is divided by the second

  MOD (%)

  REM ( R )

  /

  DIV(//)

 7. if a = 10 and b = 20, then a**b =

  20 to the power of 10

  10 to the power 20

  10 x (20x10)

  10 x 20 x 10

 8. 9//2 =

  2.5

  3.5

  4.5

  4

 9. 8 MOD 4 (or 8%4) =

  0

  2

  1

  3

 10. Consider this expression - what is the result? >> - 5 MOD 3 =

  0

  1

  2

  3

 11. We use modulo arithmetic every day. Read the following excerpt and fill in the blanks.
When reckoning hours, we count up to 12 and start again from one. 
Thus, four hours after 9 o’clock it is 1 o’clock. Numbers that 
differ by a multiple of the __________are said to be congruent 
modulo 12.

  modulus 11

  modulus 13

  modulus 14

  modulus 12

 12. Suppose today is Thursday. What weekday will it be 1,000 days from today?

  Tuesday - and this can only be worked out by looking up a digital calendar

  This cannot be worked out without very complex maths and a super computer

  1000 // 7 = 142 and 142 / 100 is the MODULUS remainder of 2, which gives us Monday

  1000%7 = 6 and the weekday 1000 days from today will be the same as in six days -i.e Wednesday

 13. Decide whether the following excerpt on the practical applications of MOD is true or false
It is used to calculate checksums for international standard book numbers 
(ISBNs) and bank identifiers (Iban numbers) and to spot errors in them.
Modular arithmetic also underlies public key cryptography systems, which 
are vital for modern commerce

  FALSE

  TRUE

 14. x += 3 is the same as x = x + 3

  TRUE

  FALSE

 15. x *= 3 is the same as x = x*3

  FALSE

  TRUE