Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个总数,比如说24 ,我需要我的代码来找到最接近10的最高倍数。这当然是30,所以我需要代码来计算(30-24)。如果数字是20,那将是20 ,因为它等于最高的10倍数。然后我需要存储结果以备后用。
>>> def nh(val): ... return 9 - ((val + 9) % 10) ... >>> nh(24) 6 >>> nh(20) 0