Python 编写一个程序,要求用户输入两个整数,并检查其中一个是否为另一个’;多倍
我应该写一个程序,要求用户输入两个整数,并检查其中一个是否是另一个整数的倍数,但我不知道怎么做 我对编程非常陌生,知道的不多,但这是我的任务之一,我需要帮助 我解决了,谢谢你的帮助Python 编写一个程序,要求用户输入两个整数,并检查其中一个是否为另一个’;多倍,python,Python,我应该写一个程序,要求用户输入两个整数,并检查其中一个是否是另一个整数的倍数,但我不知道怎么做 我对编程非常陌生,知道的不多,但这是我的任务之一,我需要帮助 我解决了,谢谢你的帮助 number= input("Type your first number: ") checkomundo= input("Type your second number: ") first= int(number) % int(checkomundo) last= int(checkomundo) % in
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("")
要向用户询问输入,您可以使用“输入”: 您可以在此处找到更多信息: 要检查一个数是否是另一个数的倍数,可以使用“%”(模)。 您可以检查此条件,例如:
if integer1 % integer2 == 0:
如果结果为0,则整数1是整数2的倍数
您可以在此处找到更多信息:
第6.7部分二进制算术运算
我想现在,你已经具备了解决问题所需的所有要素。Hi@RonanStanford--如果你能证明自己已经完成了一些工作,并针对你在尝试中遇到的错误提出问题,你可能会更幸运地得到帮助:)为了让你继续,你可以先看一下
输入
函数。谢谢你的建议,但我已经解决了。
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("")
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("")