ATM
Programming Basics · Python
TASK
Problem
Given `balance`, withdrawal `amount`, and remaining daily `limit`. Approve if amount is positive, divisible by 100, and does not exceed both balance and limit.
EXAMPLE
Example
10000 2500 5000
APPROVED
LIMITS
Constraints
Quantities, prices, and balances are integers from 0 to 10^9; other integer inputs have absolute value at most 10^9.
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `split()` separates one input line into individual values using spaces. `map()` applies the specified conversion to each input value. The `%` operator returns the remainder after division. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `and` requires all combined conditions to be true. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** The `%` operator returns a division remainder. Therefore `n % k` is useful for divisibility checks and for working with the last digits of a number. The expression `'APPROVED'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Combine four mandatory checks with `and`.']
ANSWER
Solution
+
b, a, l = map(int, input().split())
ok = a > 0 and a % 100 == 0 and (a <= b) and (a <= l)
if ok:
print('APPROVED')
else:
print('DECLINED')