Preview

08 - Operators Simple Calculations

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

  multiplication

  subtraction

  division

  addition

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

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

  print, var

  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 = 13

  10 DIV 3 = 0

  10 DIV 3 = 7

  10 DIV 3 = 3

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

  None of the above

  rounding to the nearest integer

  adding decimal points where necessary

  dividing the decimal points by the integers

 6. 10 MOD 3 =

  2

  4

  1

  3

 7. 7 DIV 3 =

  4

  1

  3

  2

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

  1.5

  2.5

  1

  2

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

  2

  2.5

  1.5

  1

 10. 5 MOD 5 =

  2

  1

  3

  0

 11. 10 MOD 2 =

  0

  1

  3

  2

 12. 5 MOD 2

  1

  3

  0

  2

 13. 5 DIV 2
5 // 2 = 

  1

  2

  1.5

  2.5

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

  the multiplication

  what's inside the brackets

  the subtraction

  the addition

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

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

  All of the above

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

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