Python Program to check character is Lowercase or Uppercase

Write a Python program to check character is Lowercase or Uppercase using islower and isupper with a practical example.

Python Program to check character is Lowercase or Uppercase using islower and isupper functions

In this Python example, we use islower and isupper string functions to check a given character is lowercase or uppercase.

# Python Program to check character is Lowercase or Uppercase
ch = input("Please Enter Your Own Character : ")

if(ch.isupper()):
    print("The Given Character ", ch, "is an Uppercase Alphabet")
elif(ch.islower()):
    print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
    print("The Given Character ", ch, "is Not a Lower or Uppercase Alphabet")
Python Program to check character is Lowercase or Uppercase 1

Python Program to check character is Lowercase or not

This python program allows a user to enter any character. Next, we used Elif Statement to check the user given character is lowercase or uppercase.

  • Here, If statement checks the character is greater than or equal to small a, and less than or equal to z. If it is TRUE, it is an uppercase. Otherwise, it enters into elif statement.
  • Inside the Elif, we check the given character is greater than or equal to A, and less than or equal to Z. If it is True, its is a lowercase character. Otherwise, it is not a lower or uppercase Alphabet.
# Python Program to check character is Lowercase or Uppercase
ch = input("Please Enter Your Own Character : ")

if(ch >= 'A' and ch <= 'Z'):
    print("The Given Character ", ch, "is an Uppercase Alphabet") 
elif(ch >= 'a' and ch <= 'z'):
    print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
    print("The Given Character ", ch, "is Not a Lower or Uppercase Alphabet")

Python character is Lowercase or Uppercase output

Please Enter Your Own Character : #
The Given Character  # is Not a Lower or Uppercase Alphabet
>>> 
Please Enter Your Own Character : T
The Given Character  T is an Uppercase Alphabet
>>> 
Please Enter Your Own Character : g
The Given Character  g is a Lowercase Alphabet

Python Program to check character is Lowercase or not using ASCII Values

In this Python code, we use ASCII Values to check the character is uppercase or lowercase.

# Python Program to check character is Lowercase or Uppercase
ch = input("Please Enter Your Own Character : ")

if(ord(ch) >= 65 and ord(ch) <= 90): 
    print("The Given Character ", ch, "is an Uppercase Alphabet") 
elif(ord(ch) >= 97 and ord(ch) <= 122):
    print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
    print("The Given Character ", ch, "is Not a Lower or Uppercase Alphabet")
Please Enter Your Own Character : o
The Given Character  o is a Lowercase Alphabet
>>> 
Please Enter Your Own Character : R
The Given Character  R is an Uppercase Alphabet
>>> 
Please Enter Your Own Character : $
The Given Character  $ is Not a Lower or Uppercase Alphabet