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.
1# Take amount2amount = int(input("Enter amount: "))34# Check if divisible by all denominations5if 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
Read the amount as an integer.
- 2
Test all three denomination remainders.
- 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.
๐Related Content
- ๐
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- ๐
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- ๐ป
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum