英文:
i want to get this output : 2*2 = 4
问题
a = int(input('Multiplication: '))
b = int(input(' * '))
print(f'{a} * {b} = {a*b}')
有没有办法在一行中进行输入语句,以获取a和b的值
{a} * {b} =
我试图使输入与文本保持在同一行,a和b位于字符串之间。
英文:
a= int(input('Multiplication: '))
print(end="")
b= int(input(' * '))
print(' = ',a*b,end="")
Is there a way to make an input statement in 1 line to get the value of a and b
{a] * {b} =
I'm trying to make the input in line with the text and a and b are in between a string
答案1
得分: 1
你可以尝试以下代码,在同一行输入a
和b
的值,并打印出所需的结果。
a, b = map(int, input().split())
result = a * b
print(f"Multiplication: {a} * {b} = {result}")
英文:
You can try the following code to get the value of a
and b
when entering them on the same line and print the desired result.
a, b = map(int, input().split())
result = a * b
print(f"Multiplication: {a} * {b} = {result}")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论