# Letters.py (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-04-12 File created. # 2022-12-16 Converted to Python 3. # 'A' is a string literal in Python. The statement # letter_to_print = 'A' would make letter_to_print reference # a string, and it is somewhat difficult to increment the # character code inside the string. For this reason, this program # is written so that letter_to_print is assigned an int value. # (See program pythonfiles3\Uplow.py for more information.) # With format specifier %c it is possible to print the character # that is represented by an integer. %c can also print a single- # character string, i.e., a kind of 'char' value. # Note that a print statement automatically prints an extra # space character. def print_uppercase_letters() : print( "\nUppercase English letters are: \n" ) letter_to_print = 0x41 # character code of uppercase A while letter_to_print <= 0x5A : # the code of uppercase Z print( " %c" % letter_to_print, end="" ) letter_to_print += 1 def print_lowercase_letters() : print( "\n\nLowercase English letters are: \n" ) letter_to_print = 0x61 # character code of lowercase a while letter_to_print <= 0x7A : # the code of lowercase z print( " %c" % letter_to_print, end="" ) letter_to_print += 1 def print_letters() : print_uppercase_letters() print_lowercase_letters() # The following statement is the "main" program. print_letters() print( "\n" )