Computer Science, asked by namithahemanth16, 5 months ago

Write a program in python which accepts the user and checks whether the number is divisible by 3 and 7. display a proper message if it is divisible. Also note that the program should continue to accept the number until the user enters 0 and end when the user enter 0

Answers

Answered by anindyaadhikari13
3

Answer:

This is the required program for this question. It is written in Python.

while True:

n=int(input("Enter a number:  "))

if n==0:

 break

if n%3==0:

 print("Number is divisible by 3.")

else:

 print("Number is not divisible by 3.")

if n%7==0:

 print("Number is divisible by 7.")

else:

 print("Number is not divisible by 7.")

print()

Explanation:

  • The while loop in this program iterates infinite times. Inside the while loop, we will ask the user to enter the number. It will display the message if the number is divisible by 3 and 7 or not. If the number is 0, the loop is terminated.

See the attachment for output ☑.

Attachments:
Similar questions