0% found this document useful (0 votes)
3 views3 pages

Python Output Questions

The document contains ten Python practice questions that involve string manipulation and character processing. Each question presents a different string and requires the application of various conditions to transform the string based on character types such as letters, digits, and special characters. The output of each question is generated using print statements to display the results of the transformations.

Uploaded by

sureshd4771
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Python Output Questions

The document contains ten Python practice questions that involve string manipulation and character processing. Each question presents a different string and requires the application of various conditions to transform the string based on character types such as letters, digits, and special characters. The output of each question is generated using print statements to display the results of the transformations.

Uploaded by

sureshd4771
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Output Practice Questions

Question 1:
s = "PyTh0n @2026!"
res = ""
for ch in s:
if [Link]():
res = res + [Link]()
elif [Link]():
res = res + str(int(ch) + 1)
elif [Link]():
res = res + "_"
else:
res = res + "#"
print(res)

Question 2:
s = "Code 123 @AI"
count = 0
for ch in s:
if [Link]():
count = count + 2
elif [Link]():
count = count + 1
elif [Link]():
count = count + int(ch)
else:
count = count - 1
print(count)

Question 3:
s = "a1 B@c 9"
res = ""
for ch in s:
if [Link]():
res = res + [Link]()
elif [Link]():
res = res + [Link]()
elif [Link]():
if int(ch) % 2 == 0:
res = res + "*"
else:
res = res + "?"
else:
res = res + ch
print(res)

Question 4:
s = "Hi 5@ Py!"
res = ""
for i in range(len(s)):
if s[i].isalpha():
if i % 2 == 0:
res = res + s[i].upper()
else:
res = res + s[i].lower()
elif s[i].isdigit():
res = res + str(int(s[i]) * 2)
else:
res = res + "_"
print(res)

Question 5:
s = "Te@ch 2026!"
v = "aeiouAEIOU"
res = ""
for ch in s:
if ch in v:
res = res + "*"
elif [Link]():
res = res + ch
elif [Link]():
res = res + str(int(ch) - 1)
else:
res = res + "#"
print(res)

Question 6:
s = "Ab3 @dE9"
res = ""
for ch in s[::-1]:
if [Link]():
if [Link]():
res = res + [Link]()
else:
res = res + [Link]()
elif [Link]():
res = res + str(int(ch) * int(ch))
else:
res = res + ch
print(res)

Question 7:
s = "He110 W@rld!"
res = ""
for ch in s:
if [Link]():
if [Link](ch) > 1:
res = res + "*"
else:
res = res + ch
elif [Link]():
res = res + ch
else:
res = res + "#"
print(res)

Question 8:
s = "aB1 cD2!"
res = ""
for i in range(len(s)):
ch = s[i]
if [Link]():
res = res + chr(ord(ch) + 1)
elif [Link]():
res = res + str(int(ch) + i)
else:
res = res + str(i)
print(res)

Question 9:
s = "Py7@th9n!"
res = ""
for ch in s:
if ch == '@':
continue
elif ch == '9':
break
elif [Link]():
res = res + ch*2
elif [Link]():
res = res + str(int(ch)-1)
else:
res = res + "#"
print(res)

Question 10:
s = "A2b3 C@1"
res = ""
for ch in s:
if [Link]():
if ch in "AEIOUaeiou":
res = res + "V"
else:
res = res + "C"
elif [Link]():
if int(ch) > 2:
res = res + "+"
else:
res = res + "-"
else:
res = res + ch
print(res)

You might also like