Open2021/01/28にコメント追加1Pythonで任意の桁で切り捨て、切り上げPythonsho_ichi2022/11/24に更新def roundDown(num, digit): return num//(10**digit) * (10**digit) print(roundDown(175, 2)) # 100 def roundUp(num, digit): return (num + 10**digit - 1)//(10**digit) * (10**digit) print(roundUp(175, 3)) # 1000 もっと良い方法間違いなくある
sho_ichi2022/11/24に更新def roundDown(num, digit): return num//(10**digit) * (10**digit) print(roundDown(175, 2)) # 100 def roundUp(num, digit): return (num + 10**digit - 1)//(10**digit) * (10**digit) print(roundUp(175, 3)) # 1000 もっと良い方法間違いなくある