0% found this document useful (0 votes)
42 views1 page

Predict The Output - Ii

The document contains a series of code snippets that manipulate strings in various ways. Each snippet demonstrates different operations such as changing case, replacing characters, and formatting output based on specific conditions. The overall focus is on string processing techniques in Python.

Uploaded by

naveenshibu9
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)
42 views1 page

Predict The Output - Ii

The document contains a series of code snippets that manipulate strings in various ways. Each snippet demonstrates different operations such as changing case, replacing characters, and formatting output based on specific conditions. The overall focus is on string processing techniques in Python.

Uploaded by

naveenshibu9
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/ 1

PREDICT THE OUTPUT - II

**************************************
*********************************** 5) mystr=”cs2study@”
1) str='[email protected]' newstr = " "
m="" count = 0
for i in range(0,len(str)): for i in mystr:
if(str[i].isupper()): if count%2 !=0:
m=m+str[i].lower() newstr = newstr+str(count)
elif str[i].islower(): else:
m=m+str[i].upper() if islower(i):
else: newstr = newstr+upper(i)
if i%2==0: else:
m=m+str[i-1] newstr = newstr+i
else: count +=1
m=m+"#" newstr = newstr+mystr[:1]
print(m) print ("The new string is :",newstr)
**************************************
**************************************
2) Text="Welcome Python"
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)
***************************************
3) s=”United Nations”
for i in range(len(s)):
if i%2==0:
print(s[i],end= ‘ ‘)
elif s[i]>=’a’ and s[i]<=’z’:
print(‘*’, end= ‘ ‘)
elif s[i]>=’A’ and s[i] <=’Z’:
print(s[i:],end= ‘ ‘)
*********************************
4) data=[‘d’,’o’,’ ‘,’k’,’t’,’ ‘,’@’,’
‘,’1’,’2’,’3’,’ ‘,’!’]
for i in range(len(data)-1):
if(data[i].isupper()):
data[i]=data[i].lower()
elif(data[i].isspace()):
data[i]=data[i+1]
print (data)

You might also like