Preview

09 - Exponentiation, MOD, DIV

 1. Watch this video if possible. Fill in the blanks.
Please Excuse My Dear Aunt Sally: Parentheses come first, followed by ___________, then Multiplication and Division from left to right, and finally Addition and Subtraction from left to right.

  exponents

  ex numbers

  experience

  external division

 2. If we take the number 10 and divide it by 3 we get three and a third.

  FALSE

  TRUE

 3. DIV is different. DIV means that you only get an _________ and any fraction is ignored and rounded. 10 DIV 3 = 3

  exponent

  unexpected variable

  interruption

  integer

 4. With the modulo operator we get the remainder from the division. 10 MOD 3 = ____
Note: Watch the video that shows the application of MOD if you are able to. Knowing how MOD is used in programming will be very important.

  3

  1

  2

  4

 5. Evaluate the following arithmetic expression where a=3, b=4, c=5 ..
a^b

  

  22

  81

  34

 6. Evaluate the following arithmetic expression where a=3, b=4, c=5 …
(c-a)^b

  12

  18

  16

  15

 7. Evaluate the following arithmetic expression where a=3, b=4, c=5 ….
8*(a+c)/b

  21

  12

  16

  18

 8. Evaluate the following arithmetic expression where a=3, b=4, c=5 ….
(a+b)*(b-c)/(c-a)

  12.5

  31.5

  30.5

  100

 9. Evaluate the following arithmetic expression where a=3, b=4, c=5 …..
(b+c)/a*b

  12

  9

  11

  10

 10. What does the following algorithm do?
Input x,y
C=x MOD y
D=x DIV y
OUTPUT C,D

  input two numbers (x and y). Using MOD and dividing this by DIV C, output the result of the sum of x + Y

  none of the above

  input two letters, x and y. Using MOD and DIV, input the whole number and divide x by y

  input two numbers (x and y). Using MOD and DIV output the whole number part and the remainder for dividing X by Y.

 11. What is the output of Z for the following algorithm, when the following numbers are input. A=27, B=15, C=52.
Z=A MOD 8

  3

  7

  6

  5

 12. What is the output of Z for the following algorithm, when the following numbers are input. A=27, B=15, C=52.
Z=C DIV B

  5

  7

  3

  6

 13. What is the output of Z for the following algorithm, when the following numbers are input. A=27, B=15, C=52.
Z=(A MOD 13)+C

  5

  6

  7

  53

 14. What is the output of Z for the following algorithm, when the following numbers are input. A=27, B=15, C=52.
Z=(88 MOD B)  DIV (A MOD 5)

  8

  3

  6

  2

 15. The code below is for a Binary Search (in python). Where has DIV been used here?
def binary_search(list, int):
  high = len(list)-1
  low = 0

  while low <= high:
    mid = (high + low) // 2
    guess = list[mid]
    if guess > int:
      high = mid -1
    elif guess < int:
      low = mid + 1
    else:
      return ('{} found in list at position {}'.format(int, mid))
  return None

print(binary_search([12,15,19,23,27,29], 27))

  It hasn't

  Straight forward division (/) has been used but not DIV

  On the line that says: mid = (high + low) //2

  On the line that says: "If guess > int:"