Python中文
首页
教程
问答
标签
搜索
登录
注册
如何修复python错误(对象不可调用)
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>所以我现在正在学习Python,我编写了以下代码来练习:</p> <pre class="lang-py prettyprint-override"><code>import time from decimal import Decimal name = input("\nPlease enter your name: ") def bmi(weight, height): bmi = weight/(height**2) if bmi > 29.9: report = "obese" elif bmi <= 29.9 and bmi > 24.9: report = "overweight" elif bmi <= 24.9 and bmi > 18.5: report = "normal" elif bmi <= 18.5: report = "underweight" else: report = "to be lying" return (bmi, report) while True: weight = Decimal(input("\nEnter your weight (kg): ")) if weight == 0: print("You can't have a weight of 0. Try again!") continue if weight < 0: print("A negative weight? Really?") continue height = Decimal(input("Enter your height (cm): ")) height = height/100 bmi, report = bmi(weight, height) bmi = round(bmi, 1) time.sleep(1) print("\n" + name.title() + ", according to your BMI (" + str(bmi) + "), you are considered " + report + ".") qprompt = input("\nDo you wish to quit? (y/n): ") if qprompt == 'y': break else: continue </code></pre> <p>在while循环再次开始并且我输入了一个权重和高度之后,这段代码似乎返回了一个错误。它第一次运行良好,但在我告诉它继续运行,然后输入重量和高度后,它崩溃并给出以下错误:</p> ^{pr2}$ <p>我想我应该在这里寻求帮助,因为我无法解决问题。 谢谢!在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>你在写作</p> <pre><code>bmi = round(bmi, 1) </code></pre> <p>使<code>bmi</code>成为一个数字。在循环的下一次迭代中,您将编写</p> ^{pr2}$ <p>把它当作一个函数。在</p> <p>决定<code>bmi</code>是否是结果函数的名称,并始终使用它</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
jupyter运行一个旧的pytorch版本
8 回答
Jupyter运行不同版本的卸载库?
3 回答
Jupyter运行指定的键盘快捷键
1 回答
Jupyter通过.local文件“逃逸”virtualenv。我该如何缓解这种情况?
9 回答
Jupyter重新加载自定义样式
2 回答
Jupyter错误:“没有名为Jupyter_core.paths的模块”
5 回答
jupyter错误:无法在随机林中将决策树视为png
1 回答
Jupyter错误'内核似乎已经死亡,它将自动重新启动'为一个给定的代码块
5 回答
Jupyter错误地用阿拉伯语和字母数字元素显示Python列表
9 回答
Jupyter隐藏数据帧索引,但保留原始样式
10 回答
Jupyter集线器:启动器中出现致命错误。。。系统找不到指定的文件
3 回答
Jupyther中相同值的相同哈希,但导出到Bigquery时不相同
6 回答
Jupy上Python的读/写访问问题
4 回答
jupy上没有模块cv
4 回答
Jupy上的排序错误
8 回答
Jupy中bqplot图形的紧凑布局
9 回答
Jupy中matplotlib plot的连续更新
8 回答
Jupy中Numpy函数的文档
9 回答
Jupy中Pandas的自动完成问题
6 回答
jupy中Qt后端的Matplotlib动画
8 回答