Class Test-Strings
Class Test-Strings
str="PROGRAMM"
for i in range(len(str)):
print(str[i:len(str)-i%2])
7.
s="Cbse Exam 2019-2020"
l=['a','e','i','o','u','A','E','I','O','U']
print(s)
r=""
x=0
while x <len(s):
i=s[x]
p=s.find(i)
if i in l:
r+=str(l[p: ])
elif i.isdigit():
r+=str(l[0])
else:
r=r+i
x+=1
print(r)
8. Consider the string s1=”Global Warning”.
Write statements in python to implement the following:
(a) To replace the first occurrences of letter ‘a’ in the string with “*” .
(b) To display the starting index for the substring ‘vo’.
(c) To remove ‘Gre’ from the left of the string.
(d) Write the script and output to return the string as list using separator ‘a’ and join
them into one string using separator ‘a’
(e) Write the script and output replicate the string with 3 times and count the no of
characters in the replicated string using count()
(f) Write the script to return the index of character ‘W ‘ by specifying start, end(display
the output using two methods)
9. Given the following code, write down the output?
a=3
b=1
for I in range(a):
for j in range (b):
Print (“hello”*i+”oswal”*j)