JIT — Intro to Data Science · Python Lab · Problem 12 of 30

Scholarship eligibility

Two conditions that must both hold, a negative question, and a decision inside a decision — where four spaces decide who gets recorded.

Two conditions at once

The scholarship rule is not one test. A student needs good marks and good attendance — both, not either. And a student already holding funding is passed over however well they did. Real eligibility rules read like this, and writing them down is where most of the mistakes happen.

New words — and, or, not These join conditions into bigger conditions:
a and b is True only when both are True.
a or b is True when at least one is True — including when both are.
not a flips the answer over.
They are ordinary English words in Python, not symbols. There is no &&, no ||, no !.

and against or

marks ≥ 75attendance ≥ 80andor
TrueTrueTrueTrue
TrueFalseFalseTrue
FalseTrueFalseTrue
FalseFalseFalseFalse

The two middle rows are the whole difference, and they are the rows that decide who gets money. A student with 82 marks and 76% attendance sits in row two: and turns them down, or pays them. Both programmes run perfectly.

New word — True and False Python's two answers to any condition, written with capital letters and no quote marks. already_funded = False stores one directly. You can then test it without comparing it to anything: if not already_funded: reads as plain English and is exactly how Python wants it written.
New word — nesting An if can live inside another if. The inner one is only reached when the outer one was true, so it asks a second question of the students who already passed the first.
Nothing marks the nesting except how far the lines are pushed in. Four spaces means "inside the outer decision". Eight means "inside the inner one". Move a line between those two positions and you have changed which students it applies to, with no error and nothing on screen to tell you.

The rule you are writing

What you are building

Marks: 82 Attendance: 88 Meets the marks and attendance rule SCHOLARSHIP AWARDED Funding decision logged Assessment complete

The logging line is the one to think hardest about. It should appear for every student who meets the marks and attendance rule — including the ones already funded, who are exactly the students an auditor will ask about later.

Coming later This decides one student. Applying the same rule to a register of two hundred means either a loop, in problems 13 to 15, or a single filtered line in pandas, in problem 22.

Build the programme

Your plan

The steps still to place

The whole programme is laid out below. Five pieces are missing. Two are joining words, one is a way of asking a negative question, and two are nothing but blank space — which is what decides how deep in the decision a line sits.

Leave nothing on "choose…". A wrong pick does not always cause an error — sometimes it just prints something you did not expect, which is the harder kind of mistake to spot.

Run and read

Here is the whole programme. All three facts about the student are yours to change. The interesting case is a student who is strong on one measure and weak on the other.

Your programme

Output

Nothing has run yet.