python - 使用百分比分配和修改变量(计算)
问题描述
我是 Python 新手。我熟悉变量并为它们赋值。
但目前我陷入了以下计算。
# current volume of a water reservoir (in cubic meters)
reservoir_volume = 4.445e8
# amount of rainfall from a storm (in cubic meters)
rainfall = 5e6
# decrease the rainfall by 10% to account for runoff
rainfall*=(10/100)
# add the rainfall to the reservoir_volume
rainfall += reservoir_volume
# increase reservoir_volume by 5% to account for storm water
# that flows into the reservoir in the days following the storm
reservoir_volume *= (5/100)
# decrease reservoir_volume by 5% to account for evaporation
reservoir_volume *= (5/100)
# subtract 2.5e5 cubic meters from reservoir_volume
# to account for water that's piped to arid regions
reservoir_volume -= (2.5e5)
# print the new value of the reservoir_volume variable
print(reservoir_volume)
你能提供一些见解什么是不正确的吗?
解决方案
# The amount of rainfall from a storm (in cubic metres)
rainfall = 5e6
# decrease the rainfall variable by 10% to account for runoff
rainfall = rainfall*0.90
# add the rainfall variable to the reservoir_volume variable
reservoir_volume = reservoir_volume + rainfall
# increase reservoir_volume by 5% to account for stormwater that flows
# into the reservoir in the days following the storm
reservoir_volume = reservoir_volume*1.05
# decrease reservoir_volume by 5% to account for evaporation
reservoir_volume = reservoir_volume*0.95
# subtract 2.5e5 cubic metres from reservoir_volume to account for water
# that's piped to arid regions.
reservoir_volume = reservoir_volume - 2.5e5
# print the new value of the reservoir_volume variable
print(reservoir_volume)
推荐阅读
- dialogflow-es - 使用 Actions Sdk 设置 Dialogflow 上下文
- scala - 在 JSON 键中保留空格
- javascript - 将存储与 nuxtServerInit 中的 cookie 同步 - NuxtJS
- c++ - 在 WTableView 中包含一个按钮
- google-colaboratory - 如何在 Google Colab 中创建多行输入?
- python - 如何修复错误:/输入“公司”处的 KeyError?从数据框中选择单行时
- swift - How to compare two UIDynamicProviderColor?
- java - InvocationTargetExceptionMessage 是:无法创建新会话,因为“createSession”错误
- r - 加载预测包后找不到 tsclean() 函数?
- apache-spark - 写入行时任务失败。文件已存在