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)
(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)Marking-scheme solution
(a)
['$\displaystyle 4$', '$\displaystyle 2$', '-', 'd', 'l', 'o']
(b)
Write the output of the following code
def Exam2026(given):
new = $\displaystyle 0$
while given:
if new % $\displaystyle 2$:
new += given % $\displaystyle 10$
else:
new += given % $\displaystyle 5$
print(new, end = '-')
given //= $\displaystyle 10$
Exam2026($\displaystyle 123456$)
(b)
$\displaystyle 1$-$\displaystyle 6$-$\displaystyle 10$-$\displaystyle 13$-$\displaystyle 15$-$\displaystyle 16$-
SECTION D (4x4=$\displaystyle 16$)
Revision of PythonListsApplyshort_answer
More from Revision of Python
- State True or False: In Python, data type of 74 is same as the data type of 74.0.2026
- What will be the output of the following code snippet? t = tuple('tuple') t2 = t[2], t += t2 print(t)2026
- Assuming that D1 is a dictionary in Python, (i) Write a Python expression to check if the key, 'RNo' is…2026
- What will be the output of the following statement? print("PythonProgram"[-1:2:-2])2026
- Which of the following statements is true about dictionaries in Python?2026
- What is the output of the following code snippet? s='War and Peace by Leo Tolstoy' print(s.partition("by"))2026
- Write a Python statement to perform the following tasks: (USE BUILT IN FUNCTIONS / METHODS ONLY) (i) To…2026
- Which of the following expressions in Python evaluates to True?2026
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.