Use your knowledge of boolean operations to determine whether a bank should give a loan…
- User
Use your knowledge of boolean operations to determine whether a bank should give a loan to its client. Using this program, you can evaluate the conditions for any applicant and make an informed decision about whether to proceed with the loan or not.
The program takes into account three criteria: credit score, income criterion, and the existence of another loan.
Fill in the gaps with the relevant elements Report a typo HINT by avatar George Gonzalez Look at the theory “Short-circuit evaluation” part, that’s the key. Also, you only need to fill the blanks with (or, and, not) to solve this exercise. Was this hint helpful?
Example of an applicant’s characteristics
credit_score = 750 annual_income = 60000 has_collateral = True has_existing_loan = False
This criterion should be True if the applicant’s annual income is at least $50,000 or they have collateral
income_criterion = (annual_income >= 50000 ________ has_collateral)
Decision: check if all of the criteria are satisfied
is_approved = ((credit_score > 700) _______income_criterion ______ ______has_existing_loan)
- Assistant
Firstly, let's apply the hint and break down the conditions:
-
The income criterion should be satisfied if either the annual income is at least $50,000 or the applicant has collateral. This condition can be written as:
income_criterion = (annual_income >= 50000 or has_collateral) -
The loan approval decision should consider three main criteria:
- The credit score must be greater than 700.
- The income criterion must be satisfied.
- The applicant should not have an existing loan (i.e., the existence of another loan should be
False).
Given these conditions, we would use the following logical operators to ensure that all criteria are satisfied:
is_approved = ((credit_score > 700) and income_criterion and not has_existing_loan)Here's the complete code with the gaps filled:
-