Founding Batch Offer ยท HLD ยท LLD ยท System Design at โ‚น799 until 30 Nov

Currency Division Check

Check whether an amount divides evenly by three stated denominations. Students practice Python and conditions and distinguish this test from making change.

IntermediatePhase 1 - Level 3: Math and Number LogicExample 7 of 10
currency-division-check.py
1# Take amount
2amount = int(input("Enter amount: "))
3
4# Check if divisible by all denominations
5if amount % 2000 == 0 and amount % 500 == 0 and amount % 100 == 0:
6 print("Can be divided evenly")
7else:
8 print("Cannot be divided evenly")

Output

Enter amount: 10000
Can be divided evenly

Enter amount: 1500
Cannot be divided evenly

In this one

  • Test separate divisibility rules
  • Understand redundant conditions
  • Distinguish divisibility from change-making

How it works

  1. 1

    Read the amount as an integer.

  2. 2

    Test all three denomination remainders.

  3. 3

    Accept only when every remainder is zero.

Edge cases

Why does 1500 fail?

Why does 1500 fail?

It is not divisible by 2000.

Does zero pass?

Does zero pass?

Yes. Every tested remainder is zero, although the code does not enforce a positive amount.

What's going on

Each remainder must be zero independently. This asks whether the entire amount is an exact multiple of 2000, 500, and 100, not whether a mixture of notes can make it.

Because 2000 itself is divisible by 500 and 100, the first test already implies the other two. They remain in the example to show compound logic. An amount of 1500 fails even though some combinations of notes could make it.

Why does 1500 fail? It is not divisible by 2000.

Does zero pass? Yes. Every tested remainder is zero, although the code does not enforce a positive amount.

Quiz

Tap an option. The answer stays hidden until you pick.

Question 1

Is this a change-making algorithm?

Pick an answer to check it.

Question 2

Why does 1500 fail?

Pick an answer to check it.

Questions people ask

Why does 1500 fail?

It is not divisible by 2000.

Does zero pass?

Yes. Every tested remainder is zero, although the code does not enforce a positive amount.

Is this a change-making algorithm?

No, it checks separate divisibility rules.