<reponame>TonyJenkins/lbu-python-code<filename>labs/tony-monday-10-jg113/exam_marks_4.py
#!/usr/bin/env python3

NUMBER_OF_MARKS = 5


def avg(numbers):
    return sum(numbers) / len(numbers)


def valid_mark(mark):
    return 0 <= mark <= 100


def read_marks(number_of_marks):
    marks_read = []

    for count in range(number_of_marks):
        while True:
            mark = int(input(f'Enter mark #{count + 1}:  '))
            if valid_mark(mark):
                break
            else:
                print('Mark out of range. Try again.')
        marks_read.append(mark)

    return marks_read


def letter_grade(mark):
    if mark > 70:
        return 'A'
    elif mark > 60:
        return 'B'
    elif mark > 50:
        return 'C'
    elif mark > 40:
        return 'D'
    else:
        return 'F'


def print_results(marks):
    print()
    print(f'Maximum Mark: {max(marks)}')
    print(f'Minimum Mark: {min(marks)}')
    print(f'Average Mark: {avg(marks):.2f}')
    print()
    print(f'Grade:        {letter_grade(avg(marks))}')


if __name__ == '__main__':

    mark_list = read_marks(NUMBER_OF_MARKS)
    print_results(mark_list)

#!/usr/bin/env python3

NUMBER_OF_MARKS = 5


def avg(numbers):
    return sum(numbers) / len(numbers)


def valid_mark(mark):
    return 0 <= mark <= 100


def read_marks(number_of_marks):
    marks_read = []

    for count in range(number_of_marks):
        while True:
            mark = int(input(f'Enter mark #{count + 1}:  '))
            if valid_mark(mark):
                break
            else:
                print('Mark out of range. Try again.')
        marks_read.append(mark)

    return marks_read


def letter_grade(mark):
    if mark > 70:
        return 'A'
    elif mark > 60:
        return 'B'
    elif mark > 50:
        return 'C'
    elif mark > 40:
        return 'D'
    else:
        return 'F'


def print_results(marks):
    print()
    print(f'Maximum Mark: {max(marks)}')
    print(f'Minimum Mark: {min(marks)}')
    print(f'Average Mark: {avg(marks):.2f}')
    print()
    print(f'Grade:        {letter_grade(avg(marks))}')


if __name__ == '__main__':

    mark_list = read_marks(NUMBER_OF_MARKS)
    print_results(mark_list)
#!/usr/bin/env python3 #{count + 1}:  '))