Write a program that asks a user to enter two integer numbers and check if either one is another one’s multiple

Question:

I am supposed to Write a program that asks a user to enter two integer numbers and check if either one is another one’s multiple, but I don’t know how.

I am very new to programming and I don’t know a lot, but this is one of my assignments and I need help.

I solved it thanks for the help!

``````number= input("Type your first number: ")
checkomundo= input("Type your second number: ")
first= int(number) % int(checkomundo)
last= int(checkomundo) % int(number)

if first ==0 :print("Your first number is a multiple of the second")
if last ==0 :print("Your second number is a multiple of the first")
print("")
if first >0 :print("Your first number is NOT a multiple of the second")
if last >0 :print("Your second number is NOT a multiple of the first")
print("")
``````

To ask inputs to user, you can use “input”:

``````variable = input('Enter a value:')
``````

You can find more about it here: https://docs.python.org/3/library/functions.html#input

To check if a number is a multiple of another, you can use “%” (modulo).
You can check with this condition, for example:

``````if integer1 % integer2 == 0:
``````

If the result gives 0, then integer1 is a multiple of integer2

You can find more here: https://docs.python.org/3/reference/expressions.html
Part 6.7 Binary arithmetic operations

I guess that now, you have all the elements needed to solve your problem.

``````number= input("Type your first number: ")
checkomundo= input("Type your second number: ")
first= int(number) % int(checkomundo)
last= int(checkomundo) % int(number)

if first ==0 :print("Your first number is a multiple of the second")
if last ==0 :print("Your second number is a multiple of the first")
print("")
if first >0 :print("Your first number is NOT a multiple of the second")
if last >0 :print("Your second number is NOT a multiple of the first")
print("")
``````
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.