Preview

08 - Operators Simple Calculations

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

  division

  multiplication

  addition

  subtraction

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

  print, var

  DIV, MOD

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

  var, DIV

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

  TRUE

  FALSE

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

  10 DIV 3 = 13

  10 DIV 3 = 0

  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 =

  1

  3

  4

  2

 7. 7 DIV 3 =

  4

  1

  2

  3

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

  1.5

  2

  1

  2.5

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

  2.5

  1.5

  1

  2

 10. 5 MOD 5 =

  2

  0

  3

  1

 11. 10 MOD 2 =

  1

  0

  2

  3

 12. 5 MOD 2

  0

  2

  3

  1

 13. 5 DIV 2
5 // 2 = 

  1.5

  2.5

  2

  1

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

  the multiplication

  the subtraction

  what's inside the brackets

  the addition

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

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

  All of the above

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

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