Question 241 markShort AnswerSection B

A statement to check whether the given character, ch is an alphabet or a number.

Python Revision Tour
Checking Alphanumeric Characters — isalnum()

Official answer

Required statement:

``python

print(ch.isalnum())

`

The built-in string method isalnum() returns True if the character ch is either an alphabet letter or a digit, and False` otherwise.

Answer keywords:isalnum()isalpha()isdigit()string methodscharacter classificationalphanumeric checkbuilt-in function

Marking scheme

  1. 1.1 mark for the correct statement `print(ch.isalnum())`; the equivalent `ch.isalpha() or ch.isdigit()` is also accepted.

Hint

Look for the single string method whose name literally combines 'alphabet' and 'number' — alnum.

Quick oral answer

ch.isalnum() returns True if ch is a letter or a digit, giving a single built-in check for whether a character is alphanumeric.

Common mistakes

  1. 1.Using only `ch.isalpha()`, which checks for alphabets alone and incorrectly returns False for a digit character.
  2. 2.Forgetting that these string methods only work correctly on a SINGLE character string when checking one character; on multi-character strings they check that ALL characters satisfy the condition.

Analysis and explanation

This question tests knowledge of Python's built-in character-classification string methods.


Why ch.isalnum() is correct

  • isalnum() checks whether every character in the string is alphanumeric — meaning it is a letter (A-Z, a-z) OR a digit (0-9).
  • Since ch is a single character, ch.isalnum() directly answers 'is ch an alphabet or a number?' in one built-in call.

Equivalent alternative

  • The same check can also be written as ch.isalpha() or ch.isdigit(), which combines two separate built-in methods with a logical OR, giving an identical True/False result.

Interesting facts

`isalnum()` returns False for an empty string, since there is no character to satisfy the check — this edge case is a favourite CBSE viva question.

Python's `str.isalnum()` also returns True for many Unicode numeric and alphabetic characters beyond plain ASCII, such as accented letters and superscript digits.

Question details

Q24 of 48 questions

Board
CBSE
Class
Class 12
Subject
Computer Science
Year
2026
Section
Section B
Marks
1
Type
Short Answer
Chapter
Python Revision Tour
Topic
Checking Alphanumeric Characters — isalnum()
Bloom's level
apply
Syllabus topic
Unit 1: Computational Thinking and Programming — Strings (Built-in Method: isalnum())
Author
CBSE
Reviewed by
Padhantu Academic Team

Spotted a mistake or something unclear?

Tell us and we will fix it.

Frequently asked questions

What does ch.isalnum() return for a space character?

It returns False, since a space is neither an alphabet letter nor a digit.

Can isalpha() or isdigit() be used instead of isalnum()?

Yes, `ch.isalpha() or ch.isdigit()` gives the same True/False result as `ch.isalnum()` for a single character.