Loan Eligibility with Logical Operators

Medium ⏱ 12 min 60% acceptance ★★★★★ 4.5
Write a function is_eligible(age, income, has_default) that returns True if a person qualifies for a loan: they must be at least 21 years old AND have income of at least 30000, AND must not have a default on record. Combine the conditions using Python's and/not logical operators.

Examples

Example 1
Input
is_eligible(25, 40000, False)
Output
True
Explanation

Meets age, income, and has no default.

Example 2
Input
is_eligible(25, 40000, True)
Output
False
Explanation

Has a default on record, disqualifying them.

Example 3
Input
is_eligible(19, 50000, False)
Output
False
Explanation

Too young despite good income.

Constraints

  • age and income are numbers; has_default is a bool.

Topics

Operatorslogical operators

Companies

JPMorgan ChaseGoldman SachsHCLTech

Hints

Hint 1

Combine three conditions with `and`, negating has_default with `not`.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.