हिंदी

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

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 7
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 7: Functions - Exercise [पृष्ठ १७२]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
अध्याय 7 Functions
Exercise | Q 1. | पृष्ठ १७२
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×