In this article, we will discuss the concept of the Python Check whether the given alphabet is upper case or lowercase
In this post, we are going to learn how to check the given alphabet is in uppercase or lowercase in Python programming language
The program allows to enter an character, thereafter it checks and displays whether the given alphabet an upper case or lower case in Python language
Program 1
#python program to check Alphabet is Lowercase or Uppercase ch=input("Please enter a character: ") if(ch>='A' and ch<='Z'): print(ch," is an uppercase letter") elif (ch>='a' and ch<='z'): print(ch," is a lowercase letter") else: print(ch," is not in Alphabet")
When the above code is executed, it produces the following result
case 1
Please enter a character: A A is an uppercase letter
case 2
Please enter a character: x x is a lowercase letter
case 3
Please enter a character: $ $ is not an Alphabets
Approach
The program allows to enter a character, thereafter it checks and displays whether the given alphabet an upper case or lower case
Program 1
#python program to check Alphabet is Lowercase or Uppercase ch=input("Please enter a character: ") if(ord(ch)>=65 and ord(ch)<=90): print(ch," is a uppercase letter") elif (ord(ch)>=97 and ord(ch)<=122): print(ch," is a lowercase letter") else: print(ch," is not in Alphabet")
When the above code is executed, it produces the following result
case 1
Please enter a character: Z Z is an uppercase letter
case 2
Please enter a character: u u is a lowercase letter
case 3
Please enter a character: & & is not an Alphabets
Approach
The program allows to enter a character, thereafter it checks and displays whether the given alphabet an upper case or lower case or not
Program 3
#python program to check Alphabet is Lowercase or Uppercase ch=input("Please enter a character: ") if(ch.isupper()): print(ch," is an uppercase letter") elif (ch.islower()): print(ch," is a lowercase letter") else: print(ch," is not in Alphabet")
When the above code is executed, it produces the following result
case 1
Please enter a character: M M is an uppercase letter
case 2
Please enter a character: r r is a lowercase letter
case 3
Please enter a character: & & is not an Alphabets
Suggested for you
if statements in Python
Similar post
Check whether the given alphabet is in upper case or lowercase in Java
Check whether the given alphabet is in upper case or lowercase in C++
Check whether the given alphabet is in upper case or lowercase in C
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…