#! /usr/bin/env python # def ch_is_isbn_digit ( c ): #*****************************************************************************80 # ## CH_IS_ISBN_DIGIT returns TRUE if the character C is an ISBN digit. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 15 September 2015 # # Author: # # John Burkardt # # Parameters: # # Input, character C, the character to be checked. # # Output, logical VALUE is TRUE if C is an ISBN digit. # i0 = ord ( '0' ) i9 = ord ( '9' ) ic = ord ( c ) if ( i0 <= ic and ic <= i9 ): value = True elif ( c == 'X' or c == 'x' ): value = True else: value = False return value def ch_is_isbn_digit_test ( ): #*****************************************************************************80 # ## CH_IS_ISBN_DIGIT_TEST tests CH_IS_ISBN_DIGIT. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 15 September 2015 # # Author: # # John Burkardt # import numpy as np import platform c_test = np.array ( [ '0', '1', '2', '3', '4', \ '5', '6', '7', '8', '9', \ 'X', 'x', 'Y', '*', '?', \ ' ' ] ) print ( '' ) print ( 'CH_IS_ISBN_DIGIT_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' CH_IS_ISBN_DIGIT is TRUE if a character is an ISBN digit.' ) print ( '' ) for i in range ( 0, 16 ): c = c_test[i] value = ch_is_isbn_digit ( c ) print ( ' "%c" %s' % ( c, value ) ) # # Terminate. # print ( '' ) print ( 'CH_IS_ISBN_DIGIT_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) ch_is_isbn_digit_test ( ) timestamp ( )