[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
"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *