Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 两位数乘法(用于循环)_Python_Loops_For Loop - Fatal编程技术网

Python 两位数乘法(用于循环)

Python 两位数乘法(用于循环),python,loops,for-loop,Python,Loops,For Loop,所以,问题是有一列两位数,等于两位数*2的乘积。我该如何解决这个问题?我不知道你的意思,但我猜你需要一个两位数计算器的代码 def getProduct(n): product = 1 while (n != 0): product = product * (n % 10) n = n // 10 return product calc = list() for number in range(10, 100): num =

所以,问题是有一列两位数,等于两位数*2的乘积。我该如何解决这个问题?

我不知道你的意思,但我猜你需要一个两位数计算器的代码

def getProduct(n): 
    product = 1
    while (n != 0): 
        product = product * (n % 10) 
        n = n // 10
    return product 
calc = list()
for number in range(10, 100):
    num = getProduct(number)
    if number == 2 * num:
        calc.append(number)
print(calc)
def getProduct(n): 
    product = 1
    if (n != 0): 
        product = product * (n % 10) * (n//10)
    return product 
calc = list()
for number in range(10, 100):
    num = getProduct(number)
    if number == 2 * num:
        calc.append(number)
print(calc)


你的问题需要再细化一点。请编辑您的问题,以便容易理解您正在尝试做什么,您已经做了什么。这是您想要的还是其他什么?
def multiply(x, y):
    return x * y
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
print(num1, "*", num2, "=", multiply(num1, num2))