python - 如何划分字典值?

关闭。这个问题需要更多focused .它目前不接受答案。

想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post .

关闭 2 年前

Improve this question

我有一个字典,其中包含键和值作为列表中的整数,例如,

input: {
    'example_key1': [358, 57, 18602, 18388],
    'example_key2': [415, 12, 4800, 2013],
    'example_key3': [450, 10, 4500, 4500],
}

我希望将列表中每个键的最后一个值与倒数第二个值相除,将答案乘以 100,然后将答案输入到类似的字典中,ndigit = 1 point round。

output: {
    'example_key1': [98.8],   # [round((((18388 / 18602)) * 100), 1)]
    'example_key2': [41.9],   # [round((((2103 / 4800)) * 100), 1)]
    'example_key3': [100.0],  # [round((((4500 / 4500)) * 100), 1)]
}

相关文章:

postgresql - Ecto:如何用不同的随机数更新所有记录

r - 如何在保留 R 中的某些变量的同时将长整形为宽

reactjs - 如何触发事件 React 测试库

kubernetes - 使用 Persistent Volume Claim 时是否必须显式创建

terraform - 如何定义 "azurerm_resource_group_template_

swiftui - 编辑 : How we can alignment Image with Ima

r - 制作数据框每一列的向量并返回列表中的向量

arrays - 使用 jq 将两个 JSON 数组合并到一个文件中

unity3d - 如何将 Input.GetAxis ("Mouse X") 或 Input.Ge

python - 无法用pip安装pycuda