Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
C program to check whether a character is an Alphabets or Not

Python program to check whether a character is an Alphabets or Not

Posted on February 26, 2022February 27, 2022

Table of Contents

  • Python program to check whether a character is an Alphabets or Not
    • Code to check character is Alphabet or Not
      • Code to check the character is Alphabet or Not using If else
      • Code to check the character is Alphabet or Not using Ascii
      • Code to check the character is Alphabet or Not using isalpha() function

Python program to check whether a character is an Alphabets or Not

In this article, we will discuss the concept of Python program to check whether a character is an Alphabets or Not

In this post, we are going to learn how to write a program to  check whether given character is English alphabet or not  using  various ways in Python language

Code to check character is Alphabet or Not

Code to check the character is Alphabet or Not using If else

In this code, we are going to learn how to check  the given character is  English alphabet or not using if else statement in Python

Program 1

#Python program to check whether the character is Alphabet or not

#taking input from the user
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: ");
#Display if the character is an Alphabet
else:

   print(ch," is not an Alphabet: ");
#Display if the character isnot an Alphabet

When the above code is executed , it produces the following result

Case 1

Please enter the character as you wish: R
R is an Alphabet:

Case 2

Please enter the character as you wish: f
f is an Alphabet

Case 3

Please enter the character as you wish: 3
3 is not an Alphabet:

 

Code to check the character is Alphabet or Not using Ascii

In this code, we are going to learn how to check  the given character is  English alphabet or not using Ascii value in Python language

Program 2

#Python program to check whether the character is Alphabet or not

#taking input from the user
ch=input("Please enter the character as you wish: ")

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

   print(ch," is not an Alphabet: ");
#Display if the character isnot an Alphabet

When the above code is executed , it produces the following result

Case 1

Please enter the character as you wish: V
V is an Alphabet:

 

Case 2

Please enter the character as you wish: j
J is an Alphabet

Case 3

Please enter the character as you wish: 7
7 is not an Alphabet:

 

Code to check the character is Alphabet or Not using isalpha() function

In this code, we are going to learn how to check  the given character is  English alphabet or not using isalpha() function in Python language

Program 3

#Python program to check whether the character is Alphabet or not

#taking input from the user
ch=input("Please enter the character as you wish: ")

if(ch.isalpha()):
   print("The given character",ch," is an Alphabet: ");
#Display if the character is an Alphabet
else:

 print("The given character",ch," is not an Alphabet: ");
#Display if the character isnot an Alphabet

When the above code is executed , it produces the following result

Case 1

Please enter the character as you wish: L
The given character L is an Alphabet:

Case 2

Please enter the character as you wish: b
The given character b is an Alphabet:

Case 3

Please enter the character as you wish: %
The given character % is not an Alphabet:

 

Suggested post

Python if-elif -else statements

Python operator

 

Similar post

Java program to print all alphabets in given range

C program to print all alphabets in given range

C++ program to print all alphabets in given range

 

Java program to print all alphabets using loops

C program to print all alphabets using loops

C++ program to print all alphabets using loops

 

Java program to check whether a character is Alphabet or Not

C++ program to check whether a character is Alphabet or Not

C program to check whether a character is Alphabet or Not

Python program to check whether a character is Alphabet or Not

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes