python - 我试图打印出这个简单的方程式,但它说浮动对象不可调用
问题描述
我一直在尝试打印出这个非常简单的方程式,但我不知道为什么它不会打印出来?
fc = float(input("first cycle is "))
fp = float(input("first percent is "))
sc = float(input("second cycle is "))
sp = float(input("second percent is "))
tc = float(input("third cycle is "))
tp = float(input("third percent is "))
mem = float(input("the memory is "))
first_part = (fc * fp + (sc(1-fp)))
print(first_part)
它给了我错误“TypeError:'float'对象不可调用”
解决方案
*
不能像在代数方程中那样省略乘法运算符。解释器认为sc(1-fp)
是函数调用。
first_part = (fc * fp + (sc * (1-fp)))
推荐阅读
- c# - C# if 语句和十进制变量小于 1 且大于 0
- oracle - 使用 200 万行的 oracle 数据库在 Unix 应用程序服务器上生成 .txt(PIPE 分隔)文件
- c++ - 路径追踪:如何确保新的方向向量是关于 BSDF 的有效方向向量?
- c++ - 出现运行时错误是什么问题?
- python - 我将如何舍入代码的输出?
- makefile - Makefile 分配给特殊变量 .DEFAULT_GOAL 未展开
- python - 如何使用来自 vscode 的 flask 和 anaconda 运行 python webapp?
- javascript - 遍历节点:为什么要检查节点是否已经包含在内?
- function - Gnuplot:如何绘制前一个残差到下一个残差的总和,直到我的(n)个残差的(n-1)个总和(所需的绘图值)?
- css - 在本机反应中使用 text-align-last