Great job! We covered a ton of material in this lesson and you’ve increased the number of tools in your Python toolkit by several-fold. Let’s review what you’ve learned this lesson:
- Boolean expressions are statements that can be either
- A boolean variable is a variable that is set to either
- You can create boolean expressions using relational operators:
- Not equals:
- Greater than:
- Greater than or equal to:
- Less than:
- Less than or equal to:
ifstatements can be used to create control flow in your code.
elsestatements can be used to execute code when the conditions of an
ifstatement are not met.
elifstatements can be used to build additional checks into your
exceptstatements can be used to build error control into your code.
Let’s put these skills to the test!
The admissions office at Calvin Coolidge’s Cool College has heard about your programming prowess and wants to get a piece of it for themselves. They’ve been inundated with applications and need a way to automate the filtering process. They collect three pieces of information for each applicant:
- Their high school GPA, on a 0.0 - 4.0 scale.
- Their personal statement, which is given a score on a 1 - 100 scale.
- The number of extracurricular activities they participate in.
The admissions office has a cutoff point for each category. They want students that have a GPA of 3.0 or higher, a personal statement with a score of 90 or higher, and who participated in 3 or more extracurricular activities.
Write a function called
applicant_selector which takes three inputs,
ec_count. If the applicant meets the cutoff point for all three categories, have the function return the string:
"This applicant should be accepted."
Great! The admissions office also wants to give students who have a high GPA and a strong personal statement a chance even if they don’t participate in enough extracurricular activities.
If an applicant meets the cutoff point for GPA and personal statement score, but not the extracurricular activity count, the function should return the string:
"This applicant should be given an in-person interview."
Finally, for all other cases, the function should return the string:
"This applicant should be rejected."