SolveItNCERT · CBSE Boards

CBSE 2026 · Central · Set 4 · Q31 · 3 marks

(a)
Write the output of the following code :
def Exam2026(given) :
    new=[]
    for ch in given[1:-1]:
        if ch.isupper():
            new.reverse()
        elif ch not in new:
            new.append(ch)
        elif ch in new:
            new.pop()
    print(new)
Exam2026("Gold-24Medals")
(b)
Write the output of the following code :
def Exam2026(given):
    new = 0
    while given:
        if new % 2:
            new += given % 10
        else:
            new += given % 5
        print(new, end='-')
        given //= 10
Exam2026(123456)

Revision of PythonListsApplyshort_answer

More from Revision of Python

CBSE Class 12 Computer Science past-paper question from the 2026board exam, with the answer as CBSE’s own marking scheme gives it. Where our answers come from.