QUESTION IMAGE
Question
write a python program that prompts the user to enter a number and then checks whether the number is divisible by 2, 3, or both. print out an appropriate message depending on the input. edit format table 12pt paragraph b i u a t²
Step1: Prompt user for input
num = int(input("Please enter a number: "))
Step2: Check divisibility
if num % 2 == 0 and num % 3 == 0:
print(f"{num} is divisible by both 2 and 3.")
elif num % 2 == 0:
print(f"{num} is divisible by 2.")
elif num % 3 == 0:
print(f"{num} is divisible by 3.")
else:
print(f"{num} is not divisible by 2 or 3.")Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
num = int(input("Please enter a number: "))
if num % 2 == 0 and num % 3 == 0:
print(f"{num} is divisible by both 2 and 3.")
elif num % 2 == 0:
print(f"{num} is divisible by 2.")
elif num % 3 == 0:
print(f"{num} is divisible by 3.")
else:
print(f"{num} is not divisible by 2 or 3.")