def calculate_sum(): """Continuously prompts for numbers using a while loop until 0 is entered.""" total = 0 while True: num = float(input("Enter a number (or 0 to finish): ")) if num == 0: break total += num return total def display_total(total_value): """Displays the final calculated sum using parameter passing.""" if total_value.is_integer(): print(f"\nThe final total is: {int(total_value)}") else: print(f"\nThe final total is: {total_value}") def main(): final_sum = calculate_sum() display_total(final_sum) if __name__ == "__main__": main()