CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Write a program to check the divisibility of a number by 7 that is passed as a parameter to the user-defined function.

Open in App
Solution

Program:
#defining the function to check the divisibility using modulus operator
def checkDivisibility(n):
if n % 7 == 0:
print(n, "is divisible by 7")
else:
print(n, "is not divisible by 7")

#asking 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 7

flag
Suggest Corrections
thumbs-up
7
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Why Divisibility Rules?
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon