# InputOutput.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-23 File created. # 2022-12-16 Converted to Python 3. # This is a module named InputOutput and the functions of this # module are used by the SortMain.py program def ask_numbers_to_list( list_of_numbers ) : number_of_given_numbers = 0 keyboard_input_is_numerical = True while keyboard_input_is_numerical == True : try : print( " Enter a number: ", end="" ) number_from_keyboard = float( input() ) list_of_numbers.append( number_from_keyboard ) number_of_given_numbers += 1 except : keyboard_input_is_numerical = False return number_of_given_numbers def print_list_of_numbers( list_of_numbers, number_of_numbers_to_print ) : for number_index in range( number_of_numbers_to_print ) : if number_index % 5 == 0 : print( "" ) # start a new line print( "%9.3f" % list_of_numbers[ number_index ], end="" )