;

Python Program to check if a Given Character is Uppercase or Not


Tutorialsrack 26/04/2020 Python

In this python program, we will learn how to check if a given character is uppercase or not. In this program, we will use two ways to check if the character is lowercase or not. First by checking if the given character is in between A-Z and the other way to check is by using built-in python function: isupper().

Here is the source code of the program to check if a given character is uppercase or not.

Program 1: Python Program to check if a Character is Uppercase or Not

Python Program to check if a Character is Uppercase or Not

# Python Program to check if a Character is Uppercase or Not

# Take the Input from the User
ch = input("Enter any Character: ")

if(ch >= 'A' and ch <= 'Z'):
    print("The Given Character", ch, "is an Uppercase Alphabet")
else:
    print("The Given Character", ch, "is not an Uppercase Alphabet")
Output

Enter any Character: A

The Given Character A is an Uppercase Alphabet

 

Enter any Character: x

The Given Character x is not an Uppercase Alphabet

Program 2: Python Program to Check if a Character is Uppercase or Not - using isupper() function

Python Program to Check if a Character is Uppercase or Not - using isupper() function
# Python Program to Check if a Character is Uppercase or Not - using isupper() function

# Take the Input from the User
ch = input("Enter any Character: ")

if(ch.isupper()):
    print("The Given Character", ch, "is an Uppercase Alphabet")
else:
    print("The Given Character", ch, "is not an Uppercase Alphabet")
Output

Enter any Character: s

The Given Character s is not an Uppercase Alphabet

 

Enter any Character: D

The Given Character D is an Uppercase Alphabet


Related Posts



Comments

Recent Posts
Tags