Page 330 - Computer Science Class 11 With Functions
P. 330
4. Consider the following code segment and choose the correct output that will be produced on its execution:
message1 = "Hello how are you?"
ch = '*'
message2 = ch.join(message1)
myList = message2.split()
print(myList[0],myList[-2],sep='#')
a. H*e*l*l*o*#*a*r*e*
b. Hello##are
c. Hello******##are****
d. Error
5. Which of the following functions removes all whitespace characters from the beginning and end of the string?
a. lstrip() b. rstrip() c. allstrip() d. strip()
6. Consider the following string
slogan = "One World One Future"
Which of the following pairs of statements will yield the same output?
a. slogan[2:8] and slogan[-8:-3]
b. slogan[:4] and slogan[10:13]
c. slogan[-1:] and slogan[0:]
d. slogan[4:10:2] and slogan[-12:-16:-2]
7. Consider the following code segment and select the correct output that will be produced on its execution:.
fact = "Hardwork is the key to success"
fact.find("Key")
a. -1 b. 16 c. -14 d. Error
8. Consider the following code segment and select the correct output that will be produced on its execution:
[CBSE Sample paper 2022-23]
a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + "." + a[1] + "." + a[3]
print(b)
a. Year .0. at All the best
b. Year 0. at All the best
c. Year .022. at All the best
d. Year .0. at all the best
9. Consider the following code segment and select the correct output that will be produced on its execution:
utterance = '#You ARE 2 GOOD'
onlyAlphabets = ""
for char in utterance:
if char.isalpha():
onlyAlphabets += char
print(onlyAlphabets)
a. #You ARE 2 GOOD b. YouAREGOOD c. You ARE GOOD d. You ARE 2 GOOD
10. Which of the following statements is used to check whether a given string- sentence ends with a full stop or not?
a. sentence.startswith('.')
b. sentence.endwith('.')
c. sentence.ends('.')
d. sentence.endswith('.')
328 Touchpad Computer Science-XI

