1
내 스크립트에서 반올림 코드가 두 배로되는 문제가있어 오류를 찾을 수 없습니다. 문제가 발생하는 곳을 찾을 수없는 것 같습니다. 모든 의견을 주시면 감사하겠습니다.반올림 코드의 배가 오류
def research_rounding(first_time):
first_time = float(first_time)
if first_time == 0: #If time is 0, return 0
result_time = 0
return result_time
else: #If time is not 0, continue rounding func
first_time = str(first_time)
find_dec = "."
length = len(first_time)
found_dec = (first_time.find(find_dec))
found_whole = float(first_time[0:found_dec])
found_tenth = float(first_time[found_dec:length])
if found_tenth < 0.25 and found_whole >= 1 and found_tenth != 0:
result_time = 0.25 + found_whole
return result_time
elif found_tenth == 0 and found_whole >=1:
result_time = 0 + found_whole
return result_time
elif found_tenth == 0 and found_whole == 0:
result_time = 0
return result_time
elif found_tenth <= 0.5:
result_time = 0.5 + found_whole
return result_time
elif found_tenth > 0.5 and found_tenth < 0.75:
result_time = 0.75 + found_whole
return result_time
elif found_tenth > 0.75 and found_tenth < 1:
result_time = 1 + found_whole
return result_time
else:
pass
무슨 문제입니까? 예상 결과와 현재 결과가 포함 된 예제를 추가하십시오. – Daniel