0% found this document useful (0 votes)
15 views5 pages

RVT Output String Q

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)
15 views5 pages

RVT Output String Q

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
You are on page 1/ 5

REVISION OF PYTHON CLASS-XI CHAPTER

Part –I-C
Write the output of the following given python code
Q.1
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=" "
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print (Msg3)
Answer
____________
Q.2
Text=”gMaIL@com”
l=len(Text)
ntext= “ “
for i in range(0,l):
if Text [i].isupper():
ntext=ntext+Text[i].lower()
elif Text[i].isalpha():
ntext=ntext+Text[i].upper()
else:
ntext=ntext+’$$’
print(ntext)

Answer
____________
Q.3
SMS='rEPorTmE'
l=len(SMS)
R=' '
print('Orignal:',SMS)
N=2
for c in range (l):
if c%2==0:
R+=chr(ord(SMS[c])+N)
elif SMS[c].isupper()==True:
R+=SMS[c].lower()
else:
R+=chr(ord(SMS[c])-N)
print('Final: ',R)

Answer
____________
Q.4
T='Mind@work!'
R=''
l=len(T)
print('Orignal:',T)
for i in range(l):
if T[i].isalpha()==False:
R+='*'
elif T[i].isupper()==True:
R+=chr(ord(T[i])+1)
else:
R+=T[i+1]
print(‘Final: ‘, R)

Answer
____________
Q.5

mystr= "sTUdeNT"
newstr = " "
count = 0
for i in mystr:
if count%2 != 0:
newstr = newstr + str(count)
else:
if i.islower():
newstr = newstr + i.upper()
else:
newstr = newstr + I
count += 1
newstr = newstr + mystr[:1]
print("The new string is:", newstr)

Answer
____________
Q.6
S= ['H', 'A','R', 'M', 'O', 'N', 'I', 'O', 'U', 'S']
Size=len(S)
print(' Original List= ', S)
for i in range ( 0, Size-1,2):
temp=S[i]
S[i] =S[i+1]
S[i+1]=temp
for j in range (1, Size, 2):
if S[i]>='M' and S[i]<='U':
S[i]='@'
print(' New List= ', S)

Answer
____________
Q.7
s= 'a ProFile'
print('Orignal:',s)
l=len(s)
r=‘ '
for x in range (l):
if s[x].islower():
r+=s[x].upper()
elif s[x].isupper():
if (x%2!=0):
r+=s[x-1].lower()
else:
r+=chr(ord(s[x])-1)
else:
r+=s[x]
print('Final: ',r)

Answer
____________

PREPARED BY:
MRS SUMAN GUPTA

You might also like