# Iffing.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-02-24 File created. # 2022-12-16 Converted to Python 3. # The corresponding C++ program has the name ifascii.cpp # Note that the character that will be read from the # keyboard is a single-character string. # The literals like ' ', '9' and 'Z' are string literals in Python. # Python does not have type char, but single-character strings # are often treated like char objects. # The logical operators of Python are the keywords # and, or, and not. # The format specifier %s is used below to print the # single-character strings. The specifier %c could be used as well. print( "\n Please, type in a character: ", end="" ) given_character = input() if given_character < ' ' : print( "\n That is an unprintable character \n" ) elif given_character >= '0' and given_character <= '9' : print( "\n You hit the number key %s." % given_character ) elif given_character >= 'A' and given_character <= 'Z' : print( "\n %s is an uppercase letter. " % given_character ) elif given_character >= 'a' and given_character <= 'z' : print( "\n %s is a lowercase letter. " % given_character ) else : print( "\n %s is a special character." % given_character )