## Image Algorithms Review

### Rotate Left

Write the following function:

`def rotate_image_left(image)`

that takes a `SimpleImage` parameter called `image` and returns a version of that image, rotated 90 degrees to the left. Note that the source image's width may be different from its height, and that the dimensions of the result image reflect the rotation you have performed; the result image is as wide as the source was tall, and as tall as the source was wide.

### Flip Vertical

Write the following function:

`def flip_vertical(image)`

that flips a `SimpleImage` parameter called `image` in the vertical direction. ## Opening the Black Box

In this program, you will tackle a series of problems intended to increase your familiarity with parameters and `return` statements. Implement the following functions:

• `def in_range(n, low, high)`, which takes in three integer parameters and returns `True` if `n` is between `low` and `high` (inclusive of both ends of the range) and `False` otherwise.
• `def is_even(n)`, which takes in an integer parameter `n` and returns `True` if `n` is even and `False`. You may wish to use the `%` operator, which returns the remainder when dividing one number by the other. For instance, `7 % 3` evaluates to `1`, since the remainder when dividing 7 by 3 is 1.
• `def is_prime(n)`, which takes in an integer parameter `n` and returns `True` if `n` is prime and `False` otherwise. As a reminder, a prime number is a number which has no factors other than 1 and itself.
• `def only_one_even(num1, num2)`, which takes in two integer parameters and returns `True` if and only if exactly one of them is even.
• (challenge) `def is_power_of_two(n)`, which takes in an integer parameter `n` and returns `True` if `n` is a power of 2 and `False` otherwise. A power of 2 is a number which can be produced by repeatedly multiplying 1 by 2 (and consequently, continuously dividing the number by 2 will lead back to 1).

## Playing with Strings

### Converting Strings to Integers

Write the following function:

``` def convert_to_int(s): ```

which takes in a string parameter `s` that is the string representation of some positive integer and converts it to an integer. For example, `convert_to_int("42")` should return `42` and `convert_to_int("0")` should return `0`.

### Remove All Occurrences

Write the following function:

``` def remove_all_occurrences(s, to_remove) ```

which removes all occurences of the length-one string `to_remove` from the string `s`. Here are some sample inputs and outputs for this function:

```                ```
>>> remove_all_occurrences('This is a test', 't')
'This is a es'
>>> remove_all_occurrence('----O----', '-')
'O'
```
```

### Palindrome Checker

Write the following function:

` def is_palindrome(s) `

which returns `True` if `s` is a palindrome and `False` otherwise. As a reminder, a palindrome is a string that reads the same forwards and backwards. Your function should behave as follows on the following inputs:

```                    ```
>>> is_palindrome('brahm')
False
>>> is_palindrome('maps spam')
True
>>> is_palindrome('Maps spam')
False # uppercase 'M' and lowercase 'm' are not the same character
```
```

As an extension, write a function `is_palindrome_without_spaces(s)` that returns `True` if `s` is a palindrome when all the spaces have been removed from the string.

#### Adding Commas to Numeric Strings

In many parts of the world, when large numbers are written out, it is traditional to use separator characters to split the digits into groups. In the United States, commas are typically used to separate the digits into groups of three. For example, the number one million is usually written in the following form:

1,000,000

As you can imagine, this is probably a task that is frequently done; to allow programmers to easily display numbers in this fashion, implement the method

`def add_commas_to_numeric_string(digits)`

which takes a string of decimal digits representing a number and returns the string formed by inserting commas after every third position, from right-to-left.

Here are some sample inputs and outputs of the `add_commas_to_numeric_string` function:

```                  ```
'17'
'1,001'
'12,345,678'
'999,999,999'
```
```

If you'd like to try your solutions in PyCharm, download a starter project to import here. We've included doctests for you to test with, and running the program itself will run a series of tests.