Example
Input
enter the character A
Output
Alphabet
Required to Know
Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), Use of If-else, and Use of Data types.
Steps
Take the character as input from the user.
Check if the entered character falls under the range
a - z and A - Z
0 - 9
If the entered character does not fall under this range, print it as a special character.
Program
# This program classifies a character as alphabet, digit, or special character.
char = input("Enter a character: ")
# Check if the character is an alphabet.
if char >= 'a' and char <= 'z' or char >= 'A' and char <= 'Z':
# Print "Alphabet".
print("Alphabet")
# Check if the character is a digit.
elif char >= '0' and char <= '9':
# Print "Digits".
print("Digits")
# Otherwise, the character is a special character.
else:
# Print "Special character".
print("Special character")