Python Programming : Alphabet or not

Example

Input
Enter the character A 
Output 
Alphabet

Required to Know

Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), Use of If-else, and Use of Data types.

Steps

  • Take the character as input from the user.

  • Check if the character is falling under this two range

    • a-z

    • A-Z

  • If it falls print it as an alphabet. Otherwise, print it as not an alphabet.

Program

# This program takes a character as input and prints whether it is an alphabet.

# Get the character from the user.
char = input("Enter the character: ")

# Check if the character is an alphabet.
if char >= 'a' and char <= 'z' or char >= 'A' and char <= 'Z':
  # Print "Alphabet".
  print("Alphabet")

# Otherwise, print "Not an Alphabet".
else:
  print("Not an Alphabet")