Problem 5: Max Digit (100pts)
Write a function that takes in a non-negative integer and return its max digit. (Using floor division and modulo might be helpful here!)
def max_digit(x):
"""Return the max digit of x.
>>> max_digit(10)
1
>>> max_digit(4224)
4
>>> max_digit(1234567890)
9
>>> # make sure that you are using return rather than print
>>> a = max_digit(123)
>>> a
3
"""
pass # YOUR CODE HERE
Test your implementation with
python ok -q max_digit
.
Test your code for lab01 with
python ok
, and submit withpython ok --submit
.If you want to submit manually, you can upload
lab01.py
to OJ website.