我想要得到这个输出:2*2 = 4

huangapple go评论94阅读模式
英文:

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

你可以尝试以下代码,在同一行输入ab的值,并打印出所需的结果。

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}")

huangapple
  • 本文由 发表于 2023年8月9日 00:06:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76861360.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定