Check if a Number is Divisible by 5
Check if a number is divisible by 5.
BeginnerPhase 1 - Level 1: Simple ConditionsExample 3 of 10
check-if-a-number-is-divisible-by-5.py
1# Take a number as input2num = int(input("Enter a number: "))34# Check if divisible by 55if num % 5 == 0:6 print("Divisible by 5")7else:8 print("Not divisible by 5")
Output
Enter a number: 25 Divisible by 5 Enter a number: 13 Not divisible by 5
What's going on
A number is divisible by 5 if the remainder when divided by 5 is 0.
Key Concepts:
Use modulo operator to check divisibility
num % 5 == 0 means num is divisible by 5Otherwise, num is not divisible by 5
🔗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