Page 284 - Computer Science Class 11 Without Functions
P. 284
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('.')
B. State whether the following statements are True or False:
1. An attempt to modify a string will always yield an error. ________
2. A multi-line string is always included in triple quotes. ________
3. When a string is enclosed between double quotes, a double quote mark may be included as part of the string. ________
4. Given an integer, the function string() yields the corresponding string. ________
5. Any integer can be converted to a string using the function str(). ________
6. join() is used to concatenate two strings. ________
C. Fill in the blanks.
1. The first character of a string will always have index ____________.
2. The function ____________ returns the number of characters in a string.
3. If a string contains both alphabets and numbers, the function, isalpha() will return ________.
4. If a string is enclosed between the double quote marks, then to include the double quote mark (") in the sting, we precede
it with the symbol _____________l.
5. A character in a string can be accessed using its __________.
6. The character sequence _____________denotes a single end-of-line character.
D. Answer the following questions:
1. What is meant by indexing in the context of strings in Python? Illustrate the use of negative and non-negative indexing with
the help of an example.
2. What is the error in the following code?
282 Touchpad Computer Science-XI

