python,Jupyter笔记本中的基本说明

时间:2019-03-18 02:12:01

标签: python jupyter

如何使用格式在输出中打印“ a”和“ b”的值而不是变量?

a = 1
b = 2
c = a+b
OUTPUT  = Sum of 1 and 2  = 3

3 个答案:

答案 0 :(得分:0)

这样做是否可以解决您的问题,请运行以下命令:

O(NK)

输出:

a = 1
b = 2
c = a+b

print("The sum of", a,"and", b,"=",c)

答案 1 :(得分:0)

a = 1
b = 2
c = a+b
print("Sum of",a,"and",b,"=",c)

答案 2 :(得分:0)

如果您使用Python> 3.6,则可以改用f字符串。它们更具可读性:

a = 1
b = 2
c = a+b
print(f"The sum of {a} and {b} = {c}")

输出为:

The sum of 1 and 2 = 3