#! /usr/bin/env python # def ch_cap ( c ): #*****************************************************************************80 # ## CH_CAP capitalizes a single character. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 04 June 2015 # # Author: # # John Burkardt # # Parameters: # # Input, character C, the character to capitalize. # # Output, character C2, the capitalized character. # i = ord ( c ) if ( ord ( 'a' ) <= i and i <= ord ( 'z' ) ): i2 = i + ord ( 'A' ) - ord ( 'a' ) c2 = chr ( i2 ) else: c2 = c return c2 def ch_cap_test ( ): #*****************************************************************************80 # ## CH_CAP_TEST tests CH_CAP. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 04 June 2015 # # Author: # # John Burkardt # import platform print ( '' ) print ( 'CH_CAP_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' CH_CAP uppercases a character.' ) print ( '' ) print ( ' C CH_CAP(C)' ) print ( '' ) c = 'F' c2 = ch_cap ( c ) print ( ' %c %c' % ( c, c2 ) ) c = 'f' c2 = ch_cap ( c ) print ( ' %c %c' % ( c, c2 ) ) c = '1' c2 = ch_cap ( c ) print ( ' %c %c' % ( c, c2 ) ) c = 'b' c2 = ch_cap ( c ) print ( ' %c %c' % ( c, c2 ) ) c = '&' c2 = ch_cap ( c ) print ( ' %c %c' % ( c, c2 ) ) # # Terminate. # print ( '' ) print ( 'CH_CAP_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) ch_cap_test ( ) timestamp ( )