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.
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 ≥ 75 | attendance ≥ 80 | and | or |
|---|---|---|---|
| True | True | True | True |
| True | False | False | True |
| False | True | False | True |
| False | False | False | False |
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.
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.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
- Marks of 75 or more and attendance of 80 or more — meets the standard route.
- Of those, the ones not already funded get the scholarship.
- Either mark alone at 95 or more — qualifies as exceptional.
- Anyone else does not qualify.
What you are building
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.
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.