Preview

08 - Operators Simple Calculations

 1. In the following code the '+' operator is used for:
x=1
y=2
z=x+y
print(z)

  addition

  multiplication

  division

  subtraction

 2. Which of the following is NOT an operator
Operators
==========
+
-
/
*
print
exponential
DIV 
MOD
var

  print, var

  The only one on the list that is not an operator is MOD

  var, DIV

  DIV, MOD

 3. DIV is the operator that gives you the remainder that is left over when a number is divided by another

  FALSE

  TRUE

 4. Integer division (DIV) can be thought of as the number of times a number can be subtracted by another e.g.
Note: this is written as // in Python

  10 DIV 3 = 3

  10 DIV 3 = 13

  10 DIV 3 = 7

  10 DIV 3 = 0

 5. The key thing about DIV is that it is integer division and it has the effect of …

  None of the above

  dividing the decimal points by the integers

  adding decimal points where necessary

  rounding to the nearest integer

 6. 10 MOD 3 =

  1

  2

  4

  3

 7. 7 DIV 3 =

  4

  3

  2

  1

 8. Look at the following python code and predict the output
x=3
print(x/2)

  1.5

  2.5

  2

  1

 9. The following code using DIV (//) rather than / would give an output of:
x=3
print(x//2)

  1

  1.5

  2.5

  2

 10. 5 MOD 5 =

  0

  3

  2

  1

 11. 10 MOD 2 =

  1

  0

  2

  3

 12. 5 MOD 2

  3

  0

  1

  2

 13. 5 DIV 2
5 // 2 = 

  1

  2.5

  2

  1.5

 14. BIDMAS/BODMAS applies when you are working with formulas. What would you deal with first?
(x+y) - (x*y)

  what's inside the brackets

  the addition

  the subtraction

  the multiplication

 15. The equals sign '=' in python is used:

  to assign a function a value e.g. def function1=3

  to assign a value a variable e.g. 3=x

  to assign a variable a value e.g. x=3

  All of the above