python-3.x - 如何使半径输入自动出现(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:", )
.
我错过了什么?
解决方案
您可以为此使用 f-string:
print(f'The volume of this sphere with radius a is:{4*math.pi*a**3/3}')
推荐阅读
- php - 在 PHP 中按对象值的总和对多维数组进行排序
- mysql - SQL 时间复杂度
- javascript - 使用 Jquery.ajax().then() 时无法 .catch() 出错
- java - 插入长文本时休眠不会持续存在
- php - Jquery拖放功能问题
- r - 使用 docker 文件从源代码安装 R 包
- excel - 根据条件在新工作表中提取特定行
- php - 表单值未通过 php(服务器端)验证提交到 wamp 服务器数据库
- php - codeigniter url 中的访问被拒绝错误有 index.php
- jquery - 如何使 Font Awesome 图标可点击以在 bootstrap 3 中打开模式