1) Write a function that returns True if a number is divisible by both 3 AND 5.

You may want to remember the remainder operator, %, that == is a test for equality, and that x and y will check if both x and y are True.

The remainder operator (or "modulo" operator) gives the remainder after division:

>>> 5 // 3  # integer division
1
>>> 5 % 3
2

This works because 5 is divisible by 3 once, with 2 left over. For more information, there's a Wikipedia article.

Here is an example of using ==:

>>> x = 4
>>> y = 4
>>> x == y
True
>>> are_xy_equal = (x == y)
>>> are_xy_equal
True
>>> z = 6
>>> x == z
False
>>> are_xz_equal = (x == z)
>>> are_xz_equal
False
>>> are_xy_equal and are_xz_equal
False

Note that are_xy_equal and are_xz_equal are not functions; they are simply variables.

Example output:
>>> is_divisible(4)
False
>>> is_divisible(3)
False
>>> is_divisible(9)
False
>>> is_divisible(15)
True
>>> is_divisible(75)
True

2) Write a function that returns the "norm" of an array.

The "norm" of a vector is equal to the square root of the sum of its components squared. For a vector r = [x, y, z], for example, the "norm" would be $\left|r\right| = \sqrt{x^2 + y^2 + z^2}$.

You may want to look into the functions sqrt and sum.

Example output:
>>> x = array([3, 4, 0])
>>> norm(x)
5.0
>>> x = array([3, 4, 5])
>>> norm(x)
7.0710678118654755

3) Write a function that returns the distance between two points.

Remember that for two vectors $r_2 = \left(x_0, y_0, z_0\right), r_1 = \left(x_1, y_1, z_1\right)$, the distance between them is $d = \sqrt{(x_1 - x_0)^2 + (y_1 - y_0)^2 + (z_1 - z_0)^2}$.

Also note that norm(r) = distance(r, [0, 0, 0]), by definition.

Example output:
>>> x = array([10, 10, 10])
>>> y = array([13, 14, 10])
>>> distance(x, y)
5.0
>>> y = array([13, 14, 15])
>>> distance(x, y)
7.0710678118654755

4: Challenge) Use the image we loaded in class to determine a distance calibration for a microscope.

If I told you that 1 repeat of "black line, white line" was 1 millimeter, can you determine the distance in millimeters that corresponds to each pixel? What is the resolution in these imaging conditions?

The data file is available here, and an example of how to load and use it is at the end of Workshop 2.