#! /usr/bin/env python # def i4_to_isbn_digit ( i ): #*****************************************************************************80 # ## I4_TO_ISBN_DIGIT converts an integer to an ISBN digit. # # Discussion: # # Only the integers 0 through 10 can be input. The representation # of 10 is 'X'. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 16 September 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer I, an integer between 0 and 10. # # Output, character VALUE, the ISBN character code of the integer. # If I is illegal, then VALUE is set to '?'. # if ( i == 0 ): value = '0' elif ( i == 1 ): value = '1' elif ( i == 2 ): value = '2' elif ( i == 3 ): value = '3' elif ( i == 4 ): value = '4' elif ( i == 5 ): value = '5' elif ( i == 6 ): value = '6' elif ( i == 7 ): value = '7' elif ( i == 8 ): value = '8' elif ( i == 9 ): value = '9' elif ( i == 10 ): value = 'X' else: value = '?' return value def i4_to_isbn_digit_test ( ): #*****************************************************************************80 # ## I4_TO_ISBN_DIGIT_TEST tests I4_TO_ISBN_DIGIT. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 September 2015 # # Author: # # John Burkardt # import platform print ( '' ) print ( 'I4_TO_ISBN_DIGIT_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' I4_TO_ISBN_DIGIT converts digits 0 to 10 to an ISBN digit.' ) print ( '' ) for i4 in range ( 0, 11 ): c = i4_to_isbn_digit ( i4 ) print ( ' %8d "%c"' % ( i4, c ) ) # # Terminate. # print ( '' ) print ( 'I4_TO_ISBN_DIGIT_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) i4_to_isbn_digit_test ( ) timestamp ( )