[Type C] Python Revision Tour-1 – Chapter 1
Table of Contents
4. Write a Python program that accepts two integers from the user and prints a message saying if the first number is divisible by the second number or if it is not.
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
if num2 == 0:
print("Cannot divide by zero.")
elif num1 % num2 == 0:
print(num1, "is divisible by", num2)
else:
print(num1, "is not divisible by", num2)
Output
Enter first number: 12
Enter second number: 3
12 is divisible by 3