CBSE · 083Class XII · 2024Section C3 marks
Question 26
2 April 2024 · Computer Science (083)
Write the output on execution of the following Python code :
python
S = "Racecar Car Radar"
L = S.split()
for W in L:
x = W.upper()
if x == x[::-1]:
for I in x:
print(I, end="*")
else:
for I in W:
print(I, end="#")
print()Answer
text
R*A*C*E*C*A*R*
C#a#r#
R*A*D*A*R*Explanation
'Racecar' and 'Radar' uppercase to palindromes (printed letter-by-letter with *). 'Car' is not a palindrome, so its original-case letters are printed with #.