Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
round関数の謎を追った。
#ダメな例
h = 0
i = str(0)
j = 11
while j != 10:
number = float(str(10.5) + (i * h) + str(1))
rounding = round(number)
print(str(number) + ' is ' + str(rounding))
h += 1
j = rounding
print("処理を終了します")
#良い例
h = 0
i = str(0)
j = 11
while j != 10:
number_str = str(10.5) + (i * h) + str(1)
number = float(number_str)
rounding = round(number)
print(number_str + ' is ' + str(rounding))
h += 1
j = rounding
print("処理を終了します")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.