225k views
0 votes
Write a program that reads two values from the user and check whether the second value is the divisor of the first value or not

User Thili
by
7.2k points

1 Answer

6 votes

Answer:

Step-by-step explanation:

Here is a simple Python program that reads two values from the user and checks whether the second value is a divisor of the first value:

# Read the two values from the user

val1 = int(input("Enter the first value: "))

val2 = int(input("Enter the second value: "))

# Check whether the second value is a divisor of the first value

if val1 % val2 == 0:

print(f"{val2} is a divisor of {val1}")

else:

print(f"{val2} is not a divisor of {val1}")

This program prompts the user to enter two values, reads them as integers, and then checks whether the second value is a divisor of the first value using the modulus operator (%). If the result of the modulus operation is 0, it means that the second value is a divisor of the first value and the program prints a message to that effect. If the result is not 0, it means that the second value is not a divisor of the first value and the program prints a different message.

I hope this helps! Let me know if you have any other questions or need further assistance.

User Burak Gavas
by
7.7k points