Advertisements
Advertisements
Question
Write a program to check the divisibility of a number by 7 that is passed as a parameter to the user-defined function.
Answer in Brief
Advertisements
Solution
Program:
#defining the function to check the divisibility using the modulus operator
def checkDivisibility(n):
if n % 7 == 0:
print(n, "is divisible by 7")
else:
print(n, "is not divisible by 7")
#asking the user to provide value for a number
n = int(input("Enter a number to check if it is divisible by 7 : "))
#calling the function
checkDivisibility(n)
OUTPUT:
Enter a number to check if it is divisible by 7 : 7712838152
7712838152 is not divisible by 7shaalaa.com
Is there an error in this question or solution?
