WorksheetsSTRING
Total questions: 13
Worksheet time: 14mins
Which of the following is not correct string?
'Computer'
"Computer"
'''Computer'''
''Computer'
str1="6/4"
print("str1")
6/4
str1
None
str1="python"
Which statement generates an error?
print(str1[2])
str1[1]="x"
print(str1[0:9])
Both (b) and (c)
Which of the following is False?
String is immutable.
capitalize() function in string is used to return a string by converting the whole given string into uppercase
lower() function in string is used to return a string by converting the whole given string into lowercase.
None of these
str1="Information"
print(str1[2:8])
format
formatio
orma
ormat
str1="Aplication"
str2=str1.replace('a','A')
print(str2)
application
Application
ApplicAtion
applicAtion
str1="poWer"
str1.upper()
print(str1)
POWER
Power
power
poWer
If str1="save paper,save plants"
str1.find("save")
0
11
None
0,11
s = 'foo'
t = 'bar'
print('barf' in 2 * (s + t))
True
False
None
print(ord('foo'))
What will you get as output?
Error
102
What is the slice expression that gives every third character of string s, starting with the last character and proceeding backward to the first?
(a)
s = 'foobar'
All of the following expressions produce the same result except one. Which one?
s[::-5]
s[::-1][-1] + s[len(s)-1]
s[0] + s[-1]
s[::-1][::-5]
s[::5]
Which of the following are true:
s[::-1][::-1] == s
s[:] is s
s[::-1][::-1] is s
s[:] == s
