Alphabet

Python programming code to check whether the character is Alphabet or not

Python programming code to check whether the character is Alphabet or not

In this post, we will discuss the concept of Python programming code to check whether the character is Alphabet or not

Here, we are going to learn how to find whether the given character is Alphabet or not in Python programming language

Alphabet or not

 

What is ASCII

In the Python programming language, all the character variables hold an ASCII value for computer usage.ASCII value is represented by integer values between 0 to 127.
The ASCII value of lowercase Alphabets are from 97 to 122 and The ASCII value of uppercase Alphabets are from 65 to 90

 

Python programming code to check whether the character is Alphabet or not

This concept is done  using two ways

  • using if-else statements
  • Using ASCII value

 

Python code to check the character is Alphabet or not using if-else

The program allows the user to enter a character thereafter it will  check and display the result of the given character whether it is an alphabet or non-alphabet using the if-else statements in Python language

Program 1

#Python programming code to check whether the character is Alphabet or not
ch=input("Please enter the character as you wish: ")

if((ch>='A' and ch<='Z')or(ch>='a' and ch<='z')):
   print(ch," is an Alphabet: ");

else:

   print(ch," is not an Alphabet: ");

When the above code is executed it produces the following result

Case 1

Enter a character as you wish: Y
Y is an Alphabet


Case 2

Enter a character as you wish: c
c is an Alphabet

 

Case 3

Enter a character as you wish: &
& is not an Alphabet

 

Approach

  • In the program, the user is asked to enter a character and entered character is stored in character variable ch
  • The program evaluates whether the entered character is an Alphabet or not, using if statements
  • If the given character is an Alphabet The program displays the output “it is an Alphabet” and if the given character is not an Alphabet it will display”it is not an Alphabet”

Python code to check the character is Alphabet or not using ASCII value

The program allows the user to enter a character thereafter it will  check and display the result of the given character whether it is an alphabet or non-alphabet using ASCII value

Program 2

#Python programming code to check whether the character is Alphabet or not
ch=input("Please enter the character as you wish")

if((ord(ch)>=65 and ord(ch)<=90)or(ord(ch)>=97 and ord(ch)<=122)):
   print(ch," is an Alphabet: ");

else:

   print(ch," is not an Alphabet: ");

 

When the above code is executed it produces the following result

Case 1

Enter a character as you wish: D
D is an Alphabet


Case 2

Enter a character as you wish: z
z is an Alphabet

 

Case 3

Enter a character as you wish: 7
7 is not an Alphabet

 

Approach

  • In the program, the user is asked to enter a character and entered character is stored in character variable ch
  • The program evaluates whether the entered character is an Alphabet or not, using ASCII value
  • If the given character is an Alphabet The program displays the output “it is an Alphabet” and if the given character is not an Alphabet it will display”it is not an Alphabet”

 

The Alphabet has ASCII values between 65 to 90(capital letters) and 97 to 122 (small letters)

 

Suggested for you

The operator in Python language

Data type in Python language

If-else statements in Python Language

 

 

Similar post

C code to check whether the character is Alphabet or not

C++ code to check whether the character is Alphabet or not

Java code to check whether the character is Alphabet or not

 

C code to check whether the Alphabet is vowel or consonant

C++ code to check whether the Alphabet is vowel or consonant

Java  code to check whether the Alphabet is vowel or consonant

 

Java program to print all upper case and lower case Alphabets

C++ program to print all upper case and lower case Alphabets

C program to print all upper case and lower case Alphabets

 

Java code to print all upper case and lower case Alphabets between the given range

C++ code to print all upper case and lower case Alphabets between the given range

C code to print all upper case and lower case Alphabets between the given range

 

 

Java programming code to check whether the character is Alphabet or not
Program to Check whether an Alphabet is vowel or consonant in Java
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

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

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago