## Class 24 — Wednesday October 24

#### Reaching an understanding with functions

Practice makes perfect — Is more than a platitude — Take it to your heart

### Look both ways

Agenda

• Another try at functions

### Example de jeur — module `primal`

• #### Function `is_factor( x, y )`

• Parameters `x` and `y` are integers. The function returns whether `y` is a factor of `x`.
• #### Function `are_relative_primes( x, y )`

• Parameters `x` and `y` are integers. The function returns whether `x` and `y` are relatively prime; i.e., whether `y` is not a factor of `x` and vice-versa.
• #### Function `is_prime( x )`

• Parameter `x` is an integer. The function returns whether `x` is prime; i.e., its only factors are 1 and itself

### Homework module take_two

• #### Function `signum( x )`

• Function parameter `x` is a numeric value. The function returns integer -1, 0, or 1 depending respectively whether `x` is negative, zero, or positive. The function does not print any output.
• #### Function `mid( s )`

• Function parameter `s` is a string. If the length of string `s` is odd, the function returns the middle character of `s`; otherwise, the function returns the two middle characters of `s`. The function does not print any output.

### To do

• Review artifacts and prior function materials