Write Python functions to determine a student’s promotability.

Thu, 20 Feb 2025 18:00

Write Python functions to determine a student’s promotability.

In Exercise 3 you wrote a script to determine whether or not a student can be promoted from Engineering One. In Lecture 5 we saw a flowchart that we can use to determine whether or not a student can be promoted from Term 3 (or any subsequent term). Now, you will write Python functions that determine whether or not a student can be promoted from Engineering One or from a higher term.

Background

Engineering One

According to §7.1 of the Faculty’s regulations, a student’s Engineering One Promotion Average is calculated based on nine courses:

Subject Courses

CHEM

1050

ENGI

1010, 1020, 1030, 1040

ENGL

1090

MATH

1001, 2050

PHYS

1051

In order to be eligible for promotion to Term 3, an Engineering One student must:

  • have an average across these nine courses of at least 65 and

  • pass all nine courses with a mark of at least 55 in each course.

Higher terms

Promotion in terms 3–8 is governed by §7.2 of the Faculty’s regulations. According to these regulations, possible promotion decisions include:

PAS (pass)

A student has passed all of their courses and achieved an average of 60% across them.

PRP (probationary promotion)

A student has achieved an average of 60% across all of their courses but did not pass all of them. The student may write re-exams in failed courses and, if successful in those re-exams, continue on to the next term.

FR3 or FR4, or…​ (fail, repeat term 3/4/5/etc.)

A student’s promotion average is below 60%, but they received a grade of at least 60% 40% in all of their courses and this is their first failure in this term.

FRW (recommended to withdraw)

A student’s promotion average is below 60%, this is their first failure in this term but at least one of their courses had a grade below 40%.

FQW (required to withdraw)

A student has failed a term for the second time, or else this is their third failed term in the program.

EA (executive action)

No decision can be taken at the present time due to missing grades (e.g., ABS for a course in which a student needs to write a deferred exam.

This logic is summarized in a flowchart in Lecture 5.

Requirements

You are to write two Python functions which conform to the following contracts:

def promotable_eo(grades):
    """Determine whether or not a student is promotable from Engineering One.

    Parameters
    ----------
    grades : iterable
        An iterable of non-negative integers, representing the student's grades in their
        Engineering One courses.

    Returns
    -------
    A boolean value indicating whether or not a student is promotable
    """

def promotion_decision(term, grades, history=[]):
    """Determine the promotability of a student in an Engineering academic term
    beyond Engineering One.

    Parameters
    ----------
    term : int
        The student's academic term (from 3 to 8, inclusive)

    grades : iterable
        Course results representing the student's grades in their courses for the term.
        These results will be strings containing either a non-negative integer or the
        string "ABS" (absent, i.e., missed the final exam and needs to write a deferred
        exam).

    history : iterable
        Strings representing the student's previous decision history, e.g.,
        ["PAS", "FR4", "PRP", "FRW"].

    Returns
    -------
    A promotion decision code, e.g., PAS, PRP, FR3, FR4, ..., FRW, FQW or EA.

Define these functions in a file called promotion.py and submit to Gradescope. As always, please don’t hesitate to contact me if you have questions! Also as always, remember that assignments are individual work.