Questions
Python program to check whether the given integer is a multiple of 5.
Last Updated : 31 Jul 2025
Jan 23, Jul 24
Solution:
# Prompt the user to enter an integer and convert it to an integer
n = int(input("Enter any number: "))
# Check if the number is a multiple of 5
if n % 5 == 0:
# If true, print that the number is a multiple of 5
print("Given number is a multiple of 5")
else:
# If false, print that the number is not a multiple of 5
print("Given number is not a multiple of 5")
OUTPUT:
Enter any number 4125
given number is multiple of 5
Explailnation:
-
Input Handling:
n = int(input("Enter any number: "))
: This line prompts the user to enter a number. The input is taken as a string, so it is converted to an integer usingint()
and stored in the variablen
.
-
Condition Checking:
if n % 5 == 0:
: This line checks ifn
is a multiple of 5. The modulus operator%
gives the remainder of the division ofn
by 5. If the remainder is 0, it meansn
is divisible by 5.
-
Output:
- If the condition is true (i.e.,
n
is a multiple of 5), it executes the first block:print("Given number is a multiple of 5")
: This prints a message confirming that the number is a multiple of 5.
- If the condition is false, it executes the
else
block:print("Given number is not a multiple of 5")
: This prints a message indicating that the number is not a multiple of 5.
- If the condition is true (i.e.,
Meanwhile you can watch this video
Watch Video