Logic Building
# Take a number as input
num = int(input("Enter a number: "))
# Check if divisible by 5
if num % 5 == 0:
print("Divisible by 5")
else:
print("Not divisible by 5")Output
Enter a number: 25 Divisible by 5 Enter a number: 13 Not divisible by 5
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 == 0means num is divisible by 5- Otherwise, num is not divisible by 5