Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program DivisionCheck in python that reads an integer and prints whether

ID: 3789152 • Letter: W

Question

Write a program DivisionCheck in python that reads an integer and prints whether it is divisible by only 2 or divisible by only 3 or divisible by both or divisible by neither 2 nor 3.

Additional Information

a) Use remainder operator

b) Use input function to receive user input

c) Get the user input by displaying the message "Enter an integer: "

d) Assume that user inputs only integers.

Expected output

Enter an integer: 5
Number 5 is divisible neither by 2 nor by 3

Enter an integer: 12
Number 12 is divisible by both 2 and 3

Enter an integer: 9
Number 9 is divisible by 3 but not 2

Enter an integer: 4
Number 4 is divisible by both 2 but not 3

Explanation / Answer


digit = input('enter digit:')
digit = int(digit)
val1=int(digit%3)
val2=int(digit%2)
if val1 == 0 and val2==0:
   print("divisble by both 2 and 3 ")
elif val1== 0:
   print("divisible by only 3")
elif val2 == 0:
   print("divisble by only 2")

output:
enter digit:3
divisible by only 3
enter digit:9
divisible by only 3

enter digit:4
divisible by only 2
enter digit:6
divisible by both 2 and 3


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote