Question:medium

Write a Python statement to perform the following tasks: (USE BUILT_IN FUNCTIONS / METHODS ONLY)

(i) To create a new list L1 containing the elements of list L arranged in ascending order, without modifying list L.

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

Show Hint

Use the built-in sorted(L) for a new sorted list, and the string method isalpha() (or isdigit()) to test a character.
Updated On: Oct 20, 2026
Show Solution

Solution and Explanation

Step 1: Pick the right tool for (i):
Two ways exist to sort a list in Python: the method L.sort() and the function sorted(L).
L.sort() works in place and returns None, so L would be changed and L1 would be None.
sorted(L) builds a fresh list, so it fits the condition that L must not be modified.

Step 2: Write and test (i):
L = [5, 2, 9, 1]
L1 = sorted(L)
print(L1)
print(L)
The output is [1, 2, 5, 9] and then [5, 2, 9, 1]. So L is untouched.

Step 3: Pick the right tool for (ii):
A character is either a letter or a digit here, so a string method that tests the type is enough.
isalpha() is True for letters. isdigit() is True for digits.
Test results: 'a'.isalpha() is True, '7'.isalpha() is False, '7'.isdigit() is True, 'a'.isdigit() is False.

Step 4: Write the statement for (ii):
ch.isalpha() answers the question. If it is True, ch is an alphabet; otherwise it is a number.
A complete one-line version is print('Alphabet' if ch.isalpha() else 'Number').

Final Answer:
(i) L1 = sorted(L)
(ii) ch.isalpha(), or ch.isdigit() for the number check
Was this answer helpful?
0