**Homeworks 5, assigned : THURS Mar 28, due THURS April 4 11:59pm.
**

All due times are 11:59 pm

### Part A

Write a program in which the main function calls a function with the heading
`def subtract(num)` that takes a three digit integer
`num`, for instance 123, and does the following

- Convert
`num` to a string `s`.
- Use the functions
`max(s)` and `min(s)` that
determine respectively the characters with the maximum and minimum (ascii) values and
assigns them to `big` and `small` in
function `subtract`. These functions are part of the Python compiler.
- Using the program we wrote in class, determine the middle digit and
assigns it to
`mid`.
- Constructs an integer,
`ascend` in which these digits appear in
ascending order. For instance, if the original value of `num` was 673,
the constructed integer would be 367.
- Repeats the last step but this time produces the digits in descending
order. So in our example, it would produce 763. It assigns this to
`descend`.
- Prints these two values.
- Subtracts these two numbers (
`descend - ascend`) and returns this
value to `main()`. So you pass an int to `subtract()` and return
an int to `main()`

### Part B

- Write another program that calls function
`subtract` defined in part
A from the main function until the function returns a value that doesn't
change, i.e., 495. To make things cleaner, don't print the output
of `subtract` from part A. Try the following approach. Before the loop
in `main()` assign 123 (or any other 3-digits number different from the
one we describe next) to `previous` and 149 (or another 3-digit number
in which all the digits are different) to `present`. Your program
should print the value of `present`. Construct the while loop as
follows:**
**while previous != present:
.............
........ = subtract(...)

So you are passing an int to `subtract()` which in turn returns an int
to `main()`.
You will see that you get a series of integers that stops at 495.

Submit part B only, with the function written in part A. The only output you
should see is what is printed in part B.