Write a Python Program to Input any 5-digit number and check whether the given number is Divisible by 7 or not
Answers
Answered by
14
The given problem is solved using language - Python.
def x():
n=int(input('Enter a five digit number: '))
if len(str(n))==5:
if n%7==0:
print('Number is divisible by 7.')
else:
print('Number is not divisible by 7.')
else:
print('Number is not a five digit number.')
# Calling x()
x()
- Accept the number from the user.
- Check if the number is a five digit number or not.
- If true, check if number is divisible by 7 or not. If true, print "Number is divisible by 7." else print "Number is not divisible by 7."
- If false, print "Number is not a five digit number."
#1
Enter a five digit number: 7777
Number is not a five digit number.
#2
Enter a five digit number: 12345
Number is not divisible by 7.
#3
Enter a five digit number: 77777
Number is divisible by 7.
Attachments:
Similar questions