412,878 views
45 votes
45 votes
Write a program in python in which teacher asks the student to check

whether the input number is divisible by 7 or not. If it is divisible by 7
then square the number and add 11 in it and then check if divisible by 2.
If it gets divisible by 2 print the original number. If it is not divisible by 2
print it “only divisible by 7”, if it is not divisible by 7 print “Not divisible
by 7”.

User Kallayya Hiremath
by
3.0k points

1 Answer

19 votes
19 votes

Answer:

number1 = int(input('Enter a number: '))

if number1 % 7 == 0:

number2 = number1*number1

number2 += 11

if number2 % 2 == 0:

print('The original number is {}'.format(number1))

else:

print('{} is only divisible by 7'.format(number1))

else:

print('{} is not divisible by 7'.format(number1))

Step-by-step explanation:

Checking the remainder after modulo operation is the way to check if a number is divisible. When it is divisible, the remainder is 0.

User Weichch
by
3.3k points