Predict The Output - Ii
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)