Ask Question
21 September, 09:56

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?

+2
Answers (1)
  1. 21 September, 10:25
    0
    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.

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers