In this Python program, we will learn how to check if a character is lowercase or not using ASCII values. For checking if a character is a lowercase alphabet or not, we will use if...elif...else
statement and ord()
function to convert a character to an ASCII value and compare it with predefined ASCII value range which starts from 0 to 127. For checking if a character is a lowercase alphabet or not, enter the alphabet from a-z or A-Z.
Here is the code of the program to check if a character is lowercase or not using ASCII values.
# Python Program to Check if a Character is Lowercase or not using ASCII Values
# Take the Input From the User
ch = input("Enter Any Character: ")
if(ord(ch) >= 97 and ord(ch) <= 122):
print("The Given Character", ch, "is a Lowercase Alphabet")
elif(ord(ch) >= 65 and ord(ch) <= 90):
print("The Given Character", ch, "is Not a Lowercase Alphabet")
else:
print("The Given Character", ch, "is Not an Alphabet Character")
Enter Any Character: 6
The Given Character 6 is Not an Alphabet Character
Enter Any Character: Z
The Given Character Z is Not a Lowercase Alphabet
Enter Any Character: q
The Given Character q is a Lowercase Alphabet
Enter Any Character: %
The Given Character % is Not an Alphabet Character
Comments