0% found this document useful (0 votes)
6 views5 pages

Question Bank 11 Half Yearly

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Question Bank 11 Half Yearly

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SKS Group of Institutions

Durgapur Public School


Session: 2025-26
QUESTION BANK
CLASS: XI SUBJECT: COMPUTER SCIENCE
CHAPTER: STRING MANIPULATION
MULTIPLE CHOICE QUESTIONS:
1. How can you concatenate two strings in Python?
a) Using the concat() method
b) Using the join() method
c) Using the & operator
d) Using the + operator

2. Which method is used to split a string into a list of substrings based on a delimiter in
Python?
a) split() b) substring()
c) separate() d) divide()

3.What does the strip() method do in Python string manipulation?


a) Removes all whitespace characters from both ends of the string
b) Removes all characters except alphabets from the string
c) Converts the string to uppercase
d) Converts the string to lowercase

4. How can you check if a string contains a specific substring in Python?


a) Using the contains() method
b) Using the in keyword
c) Using the search() function
d) Using the hasSubstring() method

5. Which method is used to find the index of the first occurrence of a substring in a string in
Python?
a) find() b) search()
c) index() d) locate()

6. What does the isdigit() method do in Python string manipulation?


a) Checks if all characters in the string are digits
b) Converts the string to lowercase
c) Checks if all characters in the string are alphabets
d) Checks if the string is empty

7. What is the output of the following Python code snippet?


string = "Hello, World!"
print(string.split(","))
a) [“Hello”, “World!”]
b) [“Hello,”, “World!”]
c) [“Hello”]
d) [“World!”]

8. What is the output of the following Python code snippet?


string = "Hello, World!"
print(string.replace("World", "Python"))
a) “Hello, Python!” b) “Hello, World!”
c) “Python, World!” d) “Python, Python!”
1
9. What is the output of the following Python code snippet?
string = "Hello, World!"
print(string[::-1])
a) “Hello, World!”
b) “dlroW ,olleH”
c) “World! Hello,”
d) “olleH ,dlroW”

10. What will be the output of the following Python code snippet?
string = "Hello, World!"
print(string.partition(","))
a) (‘Hello’, ‘,’, ‘World!’)
b) (‘Hello, ‘, ‘World’, ‘!’)
c) (‘Hello’, ‘World’, ”)
d) (‘Hello’, ‘, World’, ”)

2 MARKS QUESTIONS:
1. Which functions would you choose to use to remove leading and trailing white spaces from
a given string?
2. What is the difference between isupper() and upper function?
3. Find the output:
S=”happy”
print(“%”.join(S))
4. Write the outputs:
(a) ”apple”.startswith(“pl”)
(b) “apple”.endswith(“e”)
5. Find the errors:
S=”I love my India”
S[3]=”L”
Print(S)

3 MARKS QUESTIONS:
1. Write a program to input lines of text and apply the title function if entered text has more than
one word.
2. Write a program to input a string and character and delete the occurrence of the character in
the given string.
3. Write a program to input a string having some digits. Print the sum of digits present in its string.
4. Write a program that removes all capitalization and common punctuation from a string.
5. Why the following expressions are not a legal string operation? Give reason.
a) ‘abc’+3
b) ‘pqr’ * ’pqr’

4 MARKS QUESTIONS:
1. Write a Python program to check if a string is a palindrome.
2. Write a program to input a text of lines,( Assume each word is separated by one space). Replace
space with “-”.
3. Write the differences between split() and partition() functions.
4. a) How are strings created? Explain with examples.
b) Write a program to find the number of character ‘a’ present in the string entered by the user.
5. What kind of operations can be done over string? Explain with examples.

2
5 MARKS QUESTIONS:
1. Find the output of the following codes:
a) a=”hello”
for i in a:
print(“welcome”)

b) a=”yoga”
b=”diwas”
for i in range(len(a)):
print(a[i],b[i])
for i in range(len(a)):
print(a[i].upper(),b[i])
2. Explain the concept of string immutability in Python. Write a Python program to demonstrate how
string methods can be used to achieve seemingly "modified" strings, despite their immutable
nature. Include at least two different string methods in your demonstration.
3. Write a program to read a string and then print a string that capitalize every other letter of the string,
example CoMpUtEr.
4. Write a program that reads a line and a substring. It should then display the number of occurrences
of the given substring in the line.
5. Write a program that reads a line and print number of uppercase letters, number of lowercase
letters, number of alphabets, number of digits and number of white spaces present in the line.

CHAPTER: LIST MANIPULATION


MULTIPLE CHOICE QUESTIONS:
1. Which of the following commands will create an empty list in Python?
a) my_list = list() b) my_list = []
c) Both a and b d) my_list = list(0)
2. Given my_list = [10, 20, 30, 40, 50], what will my_list[2] return?
a) 10 b) 20
c) 30 d) 40
3. Which method is used to add an element to the end of a list?
a) insert() b) add()
c) append() d) extend()
4. Which of the following statements about Python lists is true?
a) Lists are immutable.
b) Lists are mutable.
c) Lists can only store elements of the same data type.
d) Lists cannot be nested.
5. Which of the following commands will create a list?
a) list1 = list() b) list1 = []
c) list1 = list([1, 2, 3]) d) All of the mentioned
6. What is the output of the following Python code snippet?
my_list = [1, 2, 3, 4, 5]
print(my_list[2:4])
a) [3, 4] b) [2, 3, 4]
c) [1, 2, 3] d) [4, 5]
7. Which of the following methods is used to remove the first occurrence of a specified element
from a list in Python?
a) remove() b) pop()
c) delete() d) discard()

3
8. What will be the output of the following Python code snippet?
my_list = [1, 2, 3, 4, 5]
my_list.pop(2)
print(my_list)
a) [1, 2, 4, 5]
b) [1, 2, 3, 5]
c) [1, 2, 4]
d) [1, 2, 3, 4]
9. Which of the following methods is used to insert an element at a specified position in a list in
Python?
a) insert()
b) add()
c) append()
d) put()
10. What is the output of the following Python code snippet?
my_list = [1, 2, 3, 4, 5]
my_list.insert(2, 10)
print(my_list)
a) [1, 2, 10, 3, 4, 5]
b) [1, 2, 3, 10, 4, 5]
c) [1, 2, 3, 4, 10, 5]
d) [1, 2, 3, 4, 5, 10]

2 MARKS QUESTIONS:
1. Define a list in Python.
2. What is the difference between a list and a string in Python?
3. What is list slicing?
4. Predict the output of the following :
list1 = [1, 2, 3]
list2 = list1
list2.append(4)
print(list1)
5. Predict the output of the following :
my_list = [5, 2, 8, 1, 9]
my_list.sort()
print(my_list[1:4])

3 MARKS QUESTIONS:
1. What are list slices? What for can you use them?
2. What is the difference between sort( ) and sorted( )?
3. What is the difference between following two expressions, if lst is given as [1, 3, 5]
(i) lst * 3 and lst *= 3
(ii) lst + 3 and lst += [3]
4. Write a program to create a copy of a list. In the list’s copy, add 10 to its first and last elements. then
display the list.
5. Following code prints the given list in ascending order. Modify the code so that the elements are
printed in the reverse order of the result produced by the given code.
numbers = list(range(0, 51, 4))
i=0
while i < len(numbers):
print(numbers[i] , end = " ")
i += 3
# gives output as : 0 12 24 36 48

4 MARKS QUESTIONS:
1. If a is [1, 2, 3]
a) What is the difference (if any) between a * 3 and [a, a, a]?
4
b) Is a * 3 equivalent to a + a + a?
c) What is the meaning of a[1:1] = 9?
d) What's the difference between a[1:2] = 4 and a[1:1] = 4?

2. What does each of the following expressions evaluate to? Suppose that L is
the list ["These", ["are", "a", "few", "words"], "that", "we", "will", "use"].
a) "a" in L[1][0]
b) L[:1] + L[1]
c) L[2::2]
d) L[1][0::2]
3. What do you understand by true copy of a list? How is it different from shallow copy?
4. What is the difference between appending a list and extending a list? Explain with examples.
5. (a) Write a program to finding the sum or average of elements.
(b) Write a program for finding the largest or smallest element.

5 MARKS QUESTIONS:

1. Write a program to input a list of numbers and test if a number is equal to the sum of the cubes of
its digits. Find the smallest and largest such number from the given list of numbers.
2. Write a program that inputs a list of numbers and shifts all the zeros to right and all non-zero
numbers to left of the list.
3. Write a program to compare two equal sized lists and print the first index where they differ.
4. Write a program to replace all Characters of a List Except the given character
5. Create the following list using a for loop:
a) A list containing the squares of the integers 1 through 50.
b) The list [‘a’,’bb’,’ccc’,’dddd’,………] that ends with 26 copies of z.

You might also like