0% found this document useful (0 votes)
3 views2 pages

Xi Ut2

This document is a Unit Test paper for Class XII Computer Science at Army Public School, Patiala. It includes multiple-choice questions and programming tasks related to string manipulation in Python. The test assesses students' understanding of string operations, methods, and functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Xi Ut2

This document is a Unit Test paper for Class XII Computer Science at Army Public School, Patiala. It includes multiple-choice questions and programming tasks related to string manipulation in Python. The test assesses students' understanding of string operations, methods, and functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Army Public School, Patiala.

Unit Test 2 2022 – 23


Class XII
Subject Computer Science
1. What is the output of the following code ? 1
example = "snow world"
example[3] = 's'
print (example)
(a) snow (b) snow world (c) Error (d) snos world
2. Given a string example=”hello” what is the output of example.count(‘l’) 1
(a) 2 (b) 1 (c) None (d) 0
3. What will be the output of following code 1
str = “Welcome”
str[1]=”a”
print(str)

(a) Weacome (b) error (c) Walcome (d) None


4. Which of the following operator cannot be used with string data type? 1
( a) + (b) in (c) * (d) /
5. What is the output of the following? 1
print('abcdef12'.replace('cd', '12'))
(a) ab12ef12
(b) abcdef12
(c) ab12efcd
(d) none of the mentioned
6. What is the output of the following? 1
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
(a) 0 (b) 1 (c) True (d) False
7. Write a statement to create empty string 1
8. Str = “CBSE board exams 2022” 2
w=Str.split()
print(w)
print(len(w))
9. 2

10. Consider the following string mySubject: 2


mystring = "Green Revolution"
What will be the output of the following string operations
i. print(2*mystring)
ii. print(mySubject[len(mystring)-1])
iii. print(mystring[-7:-1])
iv. print(mystring[::-2])
11. str=”[email protected]” 2
12. a) Differentiate between index() and find() methods. 2
b) Explain partition() function.
13. Write a program to get a string and a character from user create a new string after 3
removing all the occurrences of given character in the string given as input.

You might also like