126k views
5 votes
A number x is divisible by y if the remainder after the division is zero. Write a program that tests whether one number is divisible by another number. Read both numbers from the keyboard?

User Rheitzman
by
4.4k points

1 Answer

3 votes

Answer:

Program :

x=float(input("Enter first number")) #take first inputs

y=float(input("Enter second number")) #take second inputs

if(x%y==0): #check the number is divisible or not

print("The number is divisible") #print for true.

else:

print("The number is not divisible") # print for false.

Output:

  • If the user gives input 4 and 2 then it prints that it is divisible.
  • If the user gives inputs 4.2 and 2.2 then it prints that it is not divisible.

Step-by-step explanation:

  • The above program is in python language.
  • The first and second line of the program renders a message to enter the first and the second number and it take the value from the user and stored it on x and y variable after converting the value on the float.
  • Then the third line is used to check that the x and y are divisible or not. Then it prints that it is divisible for true value otherwise it prints it is not divisible.
User DazManCat
by
4.5k points