首页 > 解决方案 > 如何使半径输入自动出现(Python 3)

问题描述

我正在尝试编写一个程序来接受用户给出的输入半径。

例如:

如果半径为 2。我希望程序输出:

"The volume of this sphere with radius 2 is: 33.51"

我已经使用该变量a来存储用户输入的半径。到目前为止,我已经打印了 print("The volume of this sphere with radius a is:", ).

我错过了什么?

标签: python-3.x

解决方案


您可以为此使用 f-string:

print(f'The volume of this sphere with radius a is:{4*math.pi*a**3/3}')

推荐阅读