Advertisements
Advertisements
प्रश्न
Write a program to check the divisibility of a number by 7 that is passed as a parameter to the user-defined function.
थोडक्यात उत्तर
Advertisements
उत्तर
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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
