You are on page 1of 1

STD : XI ( 2023 – 2024 )

REVISION ACTIVITY – String manipulation


1 What is the output when following 2 What is the output when following
statement is executed ? statement is executed ?
>>>"a"+"bc" >>>"abcd"[2:]
3 What is the output when following code 4 What is the output when following code is
is executed ? executed ?
>>> str1 = 'hello' >>>print r"\nhello"
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
5 What is the output when following 6 What is the output when following
statement is executed ? statement is executed ?
>>>print('new' 'line') >>> print(‘x\21\x22’)
7 What is the output when following code 8 print(0xA + 0xB + 0xC)
is executed ?
>>>str1="HelloWorld"
>>>str1[::-1]
9 What is the output of the following? 10 What is the output of the following?
print("xyyzxyzxzxyy".count('yy')) print("abbcabcacabb".count('bb', 1))
11 What is the output of the following? 12 What is the output of the following?
print("ayycxycxcayy".count('yy', 2)) print("xyyzxyzxzxyy".count('xyy', 0, 100))
13 What is the output of the following? 14 What is the output of the following?
print("xyyzxyzxzxyy".count('xyy', 2, 11)) print("xyyzxyzxzxyy".count('xyy', -10, -1))
15 Find the output 16 Given a String s=”Covid Pandemic 19”. If
x = “Welcome Home” n=int(len(s)/2), then what will be the output
print(x[:2], x[-2:]) of the following statements:
print(x[2:-3], x[-4:-2]) >>>print(s[0:n]),
>>>print(s[0:3]),
>>>s[:n]
>>>s[n:]
17 Given a string S = “Python Program”. If 18 Write the output produced by this program
n is length/2 then what would following below:-
return? word= ‘Python World’
print((word.lower())
(a) S[:n]
print(word.replace (“World”, ‘Program’))
(b) S[n:]
print(word.upper())
(c) S[n:n]
print(word*2)
(d) S[1:n]
(e) S[n:length-1]
19 Predict output for the code 20 Predict output for the code
s="Best Wishes for Examination" s="Welcome to python programming"
print(s.lower().count('e')) print(len(s))
print(s.upper().split()) print(s[:5]+s[5:])
print(s.index('Wishes')) print(s[3:27:3]+"#$#"*3)
print(s.partition('ish')) print(s.split('o'))
print(s.replace('e','E'))

You might also like