- Write a Python program which asks the user to enter a number, if the number is divisible by 6 or 7, the program prints “The number X is divisible by 6 or 7” and if the number is neither divisible by 6 nor by 7, then it prints “The number X is not divisible by 6 and 7”.
Python Code :
n=int(input("Enter a number : ")) #Prompting user to enter a
number
if n%6==0 or n%7==0: #Checking whether the number is divisible by 6
or 7
print ('The number '+str(n)+' is divisible by 6 or 7') #Printing
that the number is divisible by 6 or 7
else :
print ('The number '+str(n)+' is not divisible by 6 or 7')
#Printing that the number is not divisible by 6 or 7
Output :
Get Answers For Free
Most questions answered within 1 hours.