Alphabet

Python Check whether the given alphabet is upper case or lowercase

Python Check whether the given alphabet is upper case or lowercase

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

Check upper case or lower case

Check whether the given alphabet is in upper  or lower using Alphabets

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

  1. Declare a variable as char ch;
  2. The user is asked to enter a character to check uppercase or lowercase
  3. Use an if statement to check uppercase, if the test expression is true,  The tested Alphabet is upper case
  4. When the if-statements is false, The control moves to elif and checks the test expression of elif
  5. If the test expression of elif is true, The tested Alphabet is lower case
  6. If the test expression of elif is false, control moves to else part and executes else part statement
  7. Finally, the program displays the character whether uppercase or lowercase or not

 

Check whether the given alphabet is in upper  or lower using ASCII

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

  1. Declare a variable as char ch;
  2. The user asked to enter a character to check uppercase or lowercase
  3. Use an if statement to check uppercase if the test expression is true,  The tested Alphabet is upper case
  4. When the if-statements is false, The control moves to elif and checks the test expression of elif
  5. If the test expression of elif is true, The tested Alphabet is lower case
  6. If the test expression of elif is false, control moves to else part and executes else part statement
  7. Finally, the program displays the character whether uppercase or lowercase or not

 

Python Check whether the given alphabet is in upper  or lower using String function

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

Operator in Python

Datatype 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

 

Check whether the given alphabet is uppercase or lowercase in Java
C++ Check whether the given alphabet is upper case or lowercase
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

3 days ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago